卸载mysql
rpm -qa|grep -i mysql
rpm -ev mysql-community-client-5.6.46-2.el7.x86_64 --nodeps
rpm -ev mysql80-community-release-el7-3.noarch --nodeps
rpm -ev mysql-community-server-5.6.46-2.el7.x86_64 --nodeps
rpm -ev MySQL-python-1.2.5-1.el7.x86_64 --nodeps
rpm -ev mysql-community-libs-5.6.46-2.el7.x86_64 --nodeps
find / -name mysql
观察如果是 mysql 的目录手动删除
(其他不相关的软件在 check 的时候会冲突, 都可以参照这个方法清理)
安装:
Mysql 5.7 安装操作手册:
MySQL :: A Quick Guide to Using the MySQL Yum Repository
Mysql 5.7 rpm 源:
https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-server-5.7.39-1.el7.x86_64.rpm
依赖:
https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-libs-5.7.39-1.el7.x86_64.rpm
https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-client-5.7.39-1.el7.x86_64.rpm
https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-common-5.7.39-1.el7.x86_64.rpm
yum install mysql-community-common-5.7.39-1.el7.x86_64.rpm
yum install mysql-community-libs-5.7.39-1.el7.x86_64.rpm
yum install mysql-community-client-5.7.39-1.el7.x86_64.rpm
yum install mysql-community-server-5.7.39-1.el7.x86_64.rpm
启动:
systemctl start mysqld
systemctl status mysqld
找到 root 的默认密码:
grep 'temporary password' /var/log/mysqld.log (/lt.tNiQW9O&)
修改root 密码:
mysql -uroot -p
(Zm12346!) // 安全策略要求有大小写
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Zm12346!';
(密码要符合安全策略:大小写+特殊字符 :ERROR 1819 (HY000): Your password does not satisfy the current policy requirements) flush privileges;
授权远程登录:
grant all privileges on *.* to 'root'@'%' identified by 'Zm12346!' with grant option;
端口配置
netstat -tulpen |grep msyql
必需要有 3306 端口, 和 0.0.0.0 : 0 0.0.0.0:3306
vi /etc/my.cnf
添加 bind-address = 0.0.0.0
systemctl restart mysqld
防火墙:
查看列表:
sudo firewall-cmd --list-all
添加到 firewall :
sudo firewall-cmd --zone=public --permanent --add-service=mysql
systemctl restart firewalld
用户名/密码
root/Zm12346!