Centos7mysql5.7安装手册的另一篇文章
Centos7默认的yum源为maridb
Yum源rpm下载
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
百度云下载 https://pan.baidu.com/s/1cJ1MKS652PsbhJx8cXIbdQ
yum localinstall mysql57-community-release-el7-8.noarch.rpm
yum repolist enabled | grep "mysql.*-community.*" #检查mysql源是否安装成功
看到上图所示表示安装成功。
可以修改vim /etc/yum.repos.d/mysql-community.repo源,改变默认安装的mysql版本。比如要安装5.6版本,将5.7源的enabled=1改成enabled=0。然后再将5.6源的enabled=0改成enabled=1即可。改完之后的效果如下所示:
yum install mysql-community-server
systemctl start mysqld
systemctl status mysqld
grep 'temporary password' /var/log/mysqld.log
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'xxxnewpasswordxxx';
大小写字母、数字和特殊符号,并且长度不能少于8位
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'xxxpasswordxxx' WITH GRANT OPTION;
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示
[mysqld] character_set_server=utf8 init_connect='SET NAMES utf8' |
重新启动mysql服务
systemctl restart mysqld
/etc/my.cnf 下面有一个my.cnf的文件然后打开
max_connections = 1000
a.查看mysql默认的引擎 按理说应该是INNODB
mysql> show variables like '%storage_engine%';
如果不是InnoDB 则需要修改
vi /etc/my.cnf
default-storage-engine=INNODB #设置默认的引擎
#innodb表的索引数据插入数据时的缓冲默认为128M,专用的mysql服务器为操作系统内存的70%-80%最佳
innodb_buffer_pool_size = 128M
query_cache_type=1 #设置查询的缓存
query_cache_size=32M (必要时可以调大点 例 如256M)
vi /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
重启防火墙
service iptables restart
systemctl enable mysqld
systemctl daemon-reload
mysql -h127.0.0.1 -uroot -p
配置文件:/etc/my.cnf
日志文件:/var/log//var/log/mysqld.log
服务启动脚本:/usr/lib/systemd/system/mysqld.service
socket文件:/var/run/mysqld/mysqld.pid
Kill -9 或者 systemctl stop mysqld
rpm -qa | grep -i mysql
rpm -ev MySQL-devel-5.6.23-1.linux_glibc2.5
或 rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
find / -name mysql
#查询
more /etc/passwd | grep mysql
more /etc/shadow | grep mysql
more /etc/group | grep mysql
//删除
userdel mysql
groupdel mysql
rpm -qa | grep -i mysql