[Solved] MYSQL Error: this authentication plugin is not supported

this authentication plugin is not supported

The application keeps reporting an error when connecting to mysql docker: this authentication plugin is not supported.
I found that the new version of mysql (8.0 or above) updated the plugin used by the root user to caching_sha2_password.
Login to mysql and enter the following command to see.

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 |
+——————+———————–+

The solutions are.
(1) Downgrade and use an older version of mysql.
(2) Change root’s plugin to mysql_native_password.
Here change it to

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

This line of code has two meanings, first: change root’s password to ‘root’, discarding the old password. Second: use mysql_native_password to encode the new password.

Then start the application again, it still reports the same error. Looking at mysql.user again, I found that there is another root user with host “%”.

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)

Change this user as well.
ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘root ‘;
See again.

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 |
+———–+——————+———————–+

The change was successful, and when I started the application, I got the following error
This user requires mysql native password authentication
Add ?allowNativePasswords=true to the url of the mysql connection, this time it works fine.
———————

Similar Posts: