参考链接 https://my.oschina.net/Laily/blog/713022
===========================================================
查找mariadb版本
rpm -qa | grep -i mariadb-libs
-- 强制卸载 mariadb
rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
依次安装
[root@centos-linux ~]# rpm -ivh mysql-community-common-5.7.17-1.el7.x86_64.rpm
[root@centos-linux ~]# rpm -ivh mysql-community-libs-5.7.17-1.el7.x86_64.rpm
[root@centos-linux ~]# rpm -ivh mysql-community-client-5.7.17-1.el7.x86_64.rpm
[root@centos-linux ~]# rpm -ivh mysql-community-server-5.7.17-1.el7.x86_64.rpm
##初始化数据
mysqld --initialize --user=mysql
查看临时密钥
# cat /var/log/mysqld.log
E*7P0qaepNzS
#启动mysql
systemctl start mysqld (stop/restart/status)
##设置密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
##开放外部访问
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'flying' WITH GRANT OPTION;
#刷新权限
FLUSH PRIVILEGES;
-- 开放端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
重启防火墙
firewall-cmd --reload
命令含义:
--zone #作用域
--add-port=80/tcp #添加端口,格式为:端口/通讯协议
--permanent #永久生效,没有此参数重启后失效
重启防火墙
0.8u*Kb0Vrij
firewall-cmd --reload
##设置密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
##开放外部访问
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;