一、下载并安装MySQL官方的 Yum Repository
wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
rpm -Uvh mysql80-community-release-el7-1.noarch.rpm
二、选择要安装的版本
查看全部
yum repolist all | grep mysql
启用对应版本
yum -y install yum-utils sudo yum-config-manager --disable mysql80-community sudo yum-config-manager --enable mysql57-community
查看已启用安装包
yum repolist enabled | grep mysql
三、安装MySQL
yum module disable mysql sudo yum install mysql-community-server
四、启动MySQL
sudo systemctl start mysqld.service
查看状态
sudo systemctl status mysqld.service
查看密码
sudo grep 'temporary password' /var/log/mysqld.log
五、配置
使用初始密码登录
mysql -uroot -p
修改root密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
开启root远程登录
use mysql; update user set Host = "%" where User = "root";
编辑配置文件
vim /etc/my.cnf
在[mysqld]下追加
character-set-server = utf8 skip-name-resolve
修改时区
default-time_zone = '+8:00'
修改sql_mode
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
修改最大链接数
max_connections = 3000
检查配置文件是否有问题
mysqld --verbose --help|grep ERROR
重启是配置生效
sudo systemctl restart mysqld.service