卸载MariaDB
1.列出所有安装的MariaDB rpm 包
rpm -qa | grep mariadb
2.强制卸载
rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
安装MySQL
1. 环境
CentOS7.5
2. 获取MySQL最新版 rpm包
yum仓库下载MySQL
yum localinstall https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
3. yum安装MySQL
yum install mysql-community-server
4. 启动MySQL服务
service mysqld start
5. MySQL服务状态
service mysqld status
6. 查看初始密码
grep 'temporary password' /var/log/mysqld.log
7. 本地MySQL客户端登录
mysql -u root -p
8. 修改root登录密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Aspirin@369';
9 .刷新
flush privileges;
10. 设置开机启动
systemctl enable mysqld.service
11. 远程连接授权
use mysql; select user,host from user; update user set host = '%' where user = 'root'; #任意ip都可以连 update user set host='your ip' where user='root'; //指定ip flush privileges;
12. 重启MySQL
systemctl restart mysqld;
13. 开放3306端口
firewall-cmd --permanent --zone=public --add-port=3306/tcp firewall-cmd --reload