1. Centos7默认安装了mariadb,需要卸载:通过 yum search mysql命令可以看到 mariadb-lib.x86_64,yum remove mariadb-lib.x86_64
2. 下载Mysql源:wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
3. 安装源:yum localinstall mysql80-community-release-el7-3.noarch.rpm
4. 安装Mysql服务(用时较长):yum install mysql-community-server
5. 查看是否已运行:ps -ef | grep mysql
6. 启动MySQL服务:service mysqld start 或者 service mysql restart
7. 查看默认密码:cat /var/log/mysqld.log | grep password
8. 通过默认密码登陆MySQL:mysql -uroot -p‘默认密码‘
9. 登陆后操作会提示修改密码,修改密码:alter user ‘root‘@‘localhost‘ identified by ‘新密码‘ (密码有字母大小写,数字,特殊字符_组成)
10. 实现远程连接,我这里是用Navicat:
用root账号登陆Linux,
然后登陆MySQL,
选择mysql库,
修改user表: alter user ‘root‘@‘localhost‘ identified with mysql_native_password by ‘新密码‘(第9步的新密码)
更新user表中root的host数据:update user set host=‘%‘ where user=‘root‘;
刷新:flush privileges;
11. Navicat测试连接,如果不行,关闭防火墙(Linux服务端:service firewalld stop)
原文地址:https://www.cnblogs.com/gangzi4321/p/11197540.html