首先查看數(shù)據(jù)庫(kù)連接加密方式
mysql> use mysql
Database changed
mysql> select user,host,plugin from user;
+------------------+-----------+-----------------------+
| user | host | plugin |
+------------------+-----------+-----------------------+
| root | % | caching_sha2_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session | localhost | caching_sha2_password |
| mysql.sys | localhost | caching_sha2_password |
| root | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+
plugin:連接加密方式
MySQL8.0加密方式為:caching_sha2_password
將需要連接的用戶加密方式改為:mysql_native_password 即可癞谒,最后FLUSH權(quán)限。
//修改加密方式并指定密碼
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '新密碼';
Query OK, 0 rows affected (0.00 sec)
//刷新權(quán)限
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
這里我修改的是root并支持外部鏈接賬號(hào)九串,可根據(jù)實(shí)際需求更改滓走。
mysql> select user,host,plugin from user;
+------------------+-----------+-----------------------+
| user | host | plugin |
+------------------+-----------+-----------------------+
| root | % | mysql_native_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session | localhost | caching_sha2_password |
| mysql.sys | localhost | caching_sha2_password |
| root | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+
5 rows in set (0.00 sec)