mysql错误:this authentication plugin is not supported

this authentication plugin is not supported

应用程序连接mysql docker一直报错:this authentication plugin is not supported。
google发现,原来是mysql新版本(8.0以上)将root用户使用的plugin更新成caching_sha2_password。
登录mysql输入如下命令可以看到:

mysql> select user,plugin from mysql.user;
+------------------+-----------------------+
| user | plugin |
+------------------+-----------------------+
| root | caching_sha2_password |
| mysql.infoschema | mysql_native_password |
| mysql.session | mysql_native_password |
| mysql.sys | mysql_native_password |
| root | caching_sha2_password |
+------------------+-----------------------+

解决办法有:
(1)降级,使用老版本mysql。
(2)将root的plugin改成mysql_native_password。
这里改成:

ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘root’;

这行代码有两层含义,第一:修改root的密码为’root’,摒弃原来的旧密码。第二:使用mysql_native_password对新密码进行编码。

然后再启动应用,还是一样报错。再看mysql.user,发现还有一个host”%”的root用户:

mysql> select host,user,plugin from mysql.user;
+-----------+------------------+-----------------------+
| host | user | plugin |
+-----------+------------------+-----------------------+
| % | root | caching_sha2_password |
| localhost | mysql.infoschema | mysql_native_password |
| localhost | mysql.session | mysql_native_password |
| localhost | mysql.sys | mysql_native_password |
| localhost | root | mysql_native_password |
+-----------+------------------+-----------------------+
5 rows in set (0.00 sec)

将这个用户也改了:
ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘root’;
再看:

mysql> select host,user,plugin from mysql.user;
+-----------+------------------+-----------------------+
| host | user | plugin |
+-----------+------------------+-----------------------+
| % | root | mysql_native_password |
| localhost | mysql.infoschema | mysql_native_password |
| localhost | mysql.session | mysql_native_password |
| localhost | mysql.sys | mysql_native_password |
| localhost | root | mysql_native_password |
+-----------+------------------+-----------------------+

改成功了,再启动应用,报错:
this user requires mysql native password authentication
在连接mysql的url上加上?allowNativePasswords=true,这次正常了。
---------------------

原文地址:https://www.cnblogs.com/mafeng/p/10122582.html

时间: 2024-10-31 04:27:23

mysql错误:this authentication plugin is not supported的相关文章

【问题解决】连接mysql 8错误:authentication plugin 'caching_sha2_password

在刚安装好mysql8,使用native连接的时候报错 authentication plugin 'caching_sha2_password'... 首先确保服务已开启,然后通过cmd命令进入mysql的localhost数据库 mysql -hlocalhost -uroot -p123456 然后进入mysql数据库 use mysql; 修改密码 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY

MySQL 连接出现 Authentication plugin 'caching_sha2_password' cannot be loaded

很多用户在使用Navicat Premium 12连接MySQL数据库时会出现Authentication plugin 'caching_sha2_password' cannot be loaded的错误,解决方法如下 1. 管理员权限运行命令提示符,登陆MySQL(记得添加环境变量) mysql -u root -p password:                                                                         #登入my

mysql 错误解决:Plugin 'FEDERATED' is disabled. /usr/sbin/mysqld: Table 'mysql.plugin' doesn't exist

今天安装完Mysql后,开启发生了错误: 1.打开相应文件夹,查看错误信息: 2.打开错误信息文件,查看错误原因是:Plugin 'FEDERATED' is disabled. /usr/sbin/mysqld: Table 'mysql.plugin' doesn't exist 3.'mysql.plugin'不存在的原因是因为新安装的mysql服务后,一般需要执行数据库初始化操作 ,从而生成与权限相关的表,执行命令如下: /usr/bin/mysql_install_db --user=

Navicat Premium 连接MySQL数据库出现Authentication plugin 'caching_sha2_password' cannot be loaded的解决方案

1.运行cmd,目录定位到MySql的安装目录“C:\Program Files\MySQL\MySQL Server 8.0\bin” 2.运行mysql 3.运行如下的两个命令 ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'

Django2.2连接MySQL报错Authentication plugin 'caching_sha2_password' cannot be loaded

之前在升级网站的时候,runserver遇到了Authentication plugin 'caching_sha2_password' cannot be loaded的报错.百度过后知道是因为MySQL8采用了caching_sha2_password的加密方式,需要改回旧的mysql_native_password,在此附上修改方法: mysql -u root -p password >ALTER USER 'root'@'localhost' IDENTIFIED BY 'passwo

Navicat 连接mysql 报错: Authentication plugin caching_ sha2_password cannot be loaded

出现这个错误的时候, 网上的资料都是修改mysql的登录信息的, ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456'; FLUSH PRIVILEGES; 但我的试了好久都没有效果, 不知道是不是我通过docker安装mysql的缘故, 或者是mysql版本的缘故. 通过这个语句, select host, user, plugin from user; 我发现我的多了一个host为%的,

MySQL Authentication plugin 'caching_sha2_password' cannot be loaded

很多用户在使用Navicat Premium 12连接MySQL数据库时会出现Authentication plugin 'caching_sha2_password' cannot be loaded的错误,解决方法如下 1. 管理员权限运行命令提示符,登陆MySQL mysql -u root -p password                                                                         #登入mysql 2. 修改账户

【问题记录】Navicat Premium连接mysql-8.0.17时出现2059 - Authentication plugin 'caching_sha2_password’....错误

问题描述: Navicat Premium连接mysql-8.0.17时出现2059 - Authentication plugin 'caching_sha2_password’ cannot be loaded:......错误 问题分析: mysql8 之前的版本中加密规则是mysql_native_password,而在mysql8之后,加密规则是caching_sha2_password. 解决办法: 1.登陆数据库:mysql - u root -p; 2.切换数据库:use mys

Authentication plugin 'caching_sha2_password' cannot be loaded错误处理

使用Navicat建立新连接时,遇到Authentication plugin 'caching_sha2_password' cannot be loaded错误: 解决方法如下: 打开mysql: 输入命令: ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;   #修改加密规则 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_nat