Mysql 8 mysql_native_password deprecation error. MY-013360

Checking in on a Mysql 8.x server the other day I found the following in the /var/log/mysql/error.log

[Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'

But not just one of them. Lots and lots of them, one a second, for the last few months. To be sure it didn't seem critical, but having lots of crap in your logs means its obscuring the really important bits, and making it hard to detect real problems.

So how to get rid of them? Well not too hard as it happens. First option is to suppress them in your mysql config. I didn't know this was an option, but yes, you can add the following line to your mysqld config file and they don't get logged any more.

log_error_suppression_list='MY-013360'

And restart. This can also be set without restarting the server using SET GLOBAL:

mysql> set global log_error_suppression_list='MY-013360' ;
Query OK, 0 rows affected (0.00 sec)

Very useful if you just want to get rid of it while you're troubleshooting something. But now to get down to the root cause. How do we fix the error completely. Again not too hard. First of all we can take a look and see which user is the offender, and the default server policy.

mysql -e " show variables like 'default_authentication_plugin';"
  default_authentication_plugin = caching_sha2_password

mysql -e "select Host,User,plugin FROM mysql.user;"
| Host  | User    | plugin |
| localhost | guilty-user | mysql_native_password |
| localhost | mysql.session | caching_sha2_password |
| localhost | mysql.sys   | caching_sha2_password |
| localhost | root    | auth_socket     |

Well it was guilty-user, what a surprise. So lets fix that. The current password for guilty-user will be known to you — it'll be in the WP config file, or database connection string of whatever app is using it. Lets say its "F$ntasticPW", so we just ALTER the user using the same password:

mysql -e "ALTER USER 'guilty-user'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'F$ntasticPW';"

And there we have it. The app shouldn't even blink. And your monster db logs are gone. But as always, take a db backup before you try.

Leave a Comment