Yum 安装方式


添加 Mysql 5.7 仓库

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

确认Mysql仓库添加成功

yum repolist all | grep mysql | grep enabled

开始安装

yum -y install mysql-community-server

启动Mysql

systemctl start mysqld
systemctl enable mysqld

安全设置

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

修改数据库编码

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

设置数据库编码为 utf8mb4

vim /etc/my.cnf

[client]
default-character-set=utf8mb4

[mysql]
default-character-set=utf8mb4

[mysqld]
collation-server = utf8mb4_unicode_ci
init-connect='SET NAMES utf8mb4'
character-set-server = utf8mb4

重启mysql

systemctl restart mysqld