MySQL连接2059报错问题

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@'%';





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章