CentOS 7 yum 安装与配置MySQL5.7

1.下载mysql源安装包

wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

2.安装mysql源

yum localinstall mysql57-community-release-el7-8.noarch.rpm
检查mysql源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"

3.安装MySQL
yum install mysql-community-server

4.启动MySQL
systemctl start mysqld

查看MySQL的启动状态
systemctl status mysqld

5.开机启动

systemctl enable mysqld
systemctl daemon-reload

6.禁用密码策略

vim /etc/my.cnf
validate_password = off

7.修改root本地登录密码

查看默认密码
grep 'temporary password' /var/log/mysqld.log
mysql -uroot -p
set password for 'root'@'localhost'=password('root123!@#');

8.配置默认编码为utf8

[mysqld]
character_set_server=utf8
[client]
default-character-set=utf8

查看编码

show variables like '%character%';

9.默认配置文件路径

配置文件:/etc/my.cnf
日志文件:/var/log//var/log/mysqld.log
服务启动脚本:/usr/lib/systemd/system/mysqld.service
socket文件:/var/run/mysqld/mysqld.pid

原文地址:https://www.cnblogs.com/taohaijun/p/7157792.html