MySQL版本是8.0.4
由於新版本的MySQL新特性導致的。
mysql> select Host,User,plugin from mysql.user;
+-----------+------------------+-----------------------+
| Host | User | plugin |
+-----------+------------------+-----------------------+
| % | root | caching_sha2_password |
| % | vuluser | caching_sha2_password |
查詢結果如上,因爲認證方式改變導致的。在老版本里,一般使用加密方式爲mysql_native_password。所以可以直接修改爲老版本的加密方式,或者升級新版本的加密方式。
這裏採用更改爲老版本的加密
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '密碼';
ALTER USER 'vuluser'@'%' IDENTIFIED WITH mysql_native_password BY '密碼';
或者,配置一下/etc/my.cnf
[mysqld]
default_authentication_plugin=mysql_native_password
改完連接沒問題,順便記一下,新版本的授權方式與老版本有點不同
老版本可以這樣寫:grant all on *.* to test@'%' identified by '密碼';
新版本不能,可以寫成這樣子:grant all on *.* to test@'%';