1.添加Mysql5.7仓库

sudo rpm -ivh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

2.确认Mysql仓库成功添加

sudo yum repolist all | grep mysql | grep enabled

3.安装Mysql5.7

sudo yum -y install mysql-community-server

4.启动Mysql

sudo systemctl start mysqld

5.设置系统启动时自动启动

sudo systemctl enable mysqld

6.查看启动状态

sudo systemctl status mysqld

7.root 密码

cat /var/log/mysqld.log | grep -i 'temporary password'

8.执行下面命令进行安全设置

这个命令会进行设置root密码设置,移除匿名用户,禁止root用户远程连接等

mysql_secure_installation

9.设置数据库编码为utf8

sudo vim /etc/my.cnf

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8

reboot

sudo systemctl restart mysqld


Re:

https://juejin.im/post/6844903732145045517