Centos7 安裝mysql8

JeffZhang2019發表於2019-03-21

Installing MySQL on Linux Using the MySQL Yum Repository
1.下載yum Repository
MySQL Yum Repository
選擇和下載release package
2.下載的是基於EL7-based 系統
yum localinstall mysql80-community-release-el7-2.noarch.rpm
3.查詢enabled 的倉庫
yum repolist enabled | grep "mysql.-community."

Centos7 安裝mysql8

4.通過下面命令安裝mysql
yum install mysql-community-server

5.通過命令啟動mysql
systemctl start mysqld

6.通過命令查詢初始密碼
grep 'temporary password' /var/log/mysqld.log

7.通過命令就可以進入
mysql -uroot -ppassword

8.修改密碼
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

9.mysql 遠端登入
use mysql;
update user set host = '%' where user = 'root';
可以通過如下命令降低密碼強度
SET GLOBAL validate_password.policy=LOW;
SET GLOBAL validate_password.length=4;
mysql8 之前的版本中加密規則是mysql_native_password,而在mysql8之後,加密規則是caching_sha2_password,
解決問題方法有兩種,一種是升級navicat驅動,一種是把mysql使用者登入密碼加密規則還原成mysql_native_password.
ALTER USER 'root'@'%' IDENTIFIED BY 'root123' PASSWORD EXPIRE NEVER;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root123';
flush privileges;
完成以上操作,則可以遠端連線上。

相關文章