1 下载源
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
2安装源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
3检查源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
4 安装MySQL
yum install mysql-community-server
5 启动MySQL服务
systemctl start mysqld
6 设置开机启动
systemctl enable mysqld
systemctl daemon-reload
7 修改root登陆密码
grep 'temporary password' /var/log/mysqld.log
alter user root@localhost identified by 'Zj31XXX!'
8 增加远程用户
GRANT ALL PRIVILEGES ON *.* TO 'zhangjin'@'%' IDENTIFIED BY 'Zj314XXX!' WITH GRANT OPTION; flush privileges;
9 修改mysql编码为UTF8mb4 支持emoji表情
修改/etc/my.cnf添加如下配置
[client]
default-character-set = utf8mb4 [mysql]
default-character-set = utf8mb4 [mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
重启MySQL
systemctl restart mysqld 之后登陆检查字符编码 SHOW VARIABLES like '%character%';
安装完成