1.移除mariadb数据库
yum remove mariadb-libs.x86_64
2.下载mysql源
wget https://dev.mysql.com/downloads/repo/yum/(使用之前先安装wget)
(https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm)
3.安装源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
4.安装mysql
yum install mysql-community-server
5.查询默认密码
cat /var/log/mysqld.log | grep "password"
6.登陆mysql
mysql -uroot -ppassword
7.修改默认密码
ALTER user 'root'@'localhost' IDENTIFIED BY 'newpassword';
8.允许远程连接mysql服务
8.1.在user表update
user set host = '%' where Host = "localhost" and User = "root";
8.2.刷新权限
flush privileges;
8.3.关闭防火墙(不推荐,开启防火墙3306端口)
firewall-cmd --zone=public --add-port=3306/tcp --permanent
注意:操作以上三步之后依旧远程连接不了mysql服务:
由于目前已有的客户端连接软件还不支持Mysql8新增加的加密方式caching_sha2_password,所以我们需要修改用户的加密方式,将其改为老的加密验证方式。
1.use mysql;
2.select user,plugin from user where user='root';
3.将用户的加密方式改为mysql_native_password。
alter user 'root'@'%' identified with mysql_native_password by 'password';
4.flush privileges