连接数据库时caching_sha2_password解决

Posted Circle-C

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了连接数据库时caching_sha2_password解决相关的知识,希望对你有一定的参考价值。

解决方法
网上流行的解决方案是把sha2认证改回以前的认证方式,方法如下:

// 启动mysql服务
mysql.server start
 
// 登录Mysql(需要输入密码) mysql -u root -p

// 选择数据库(这一步不可省略) use mysql

// 查看plugin设置 select host, user, plugin from user;

可以看到root的plugin是caching_sha2_password,我们希望改成mysql_native_password

ALTER USER root@localhost IDENTIFIED WITH mysql_native_password BY 'xxxxx';

以上是关于连接数据库时caching_sha2_password解决的主要内容,如果未能解决你的问题,请参考以下文章