How to change caching_sha2_password to mysql_native_password on a DigitalOcean's Managed MySQL Database?

I want to use the new DigitalOcean MySQL Managed Databases with my PHP application but I’m getting this error here:

ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client

Could anyone please let me know how can I change the authentication type for my **MySQL **user from caching_sha2_password to mysql_native_password?

Thank you!

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer


The easiest way to fix that would be to alter your existing user with the following:

ALTER USER myuser IDENTIFIED WITH mysql_native_password BY 'mypassword';

Another thing that you could do is to create a new user with mysql_native_password. To do that you could use the following:

CREATE USER 'your_user'@'your_server_ip ' IDENTIFIED WITH mysql_native_password BY 'your_password';

Also as mentioned by @kavo13, try to upgrade PHP to 7.2 as well.

After that, it should all work as normal.

I’ve created a quick video demo on how to do that:

I’m running the test on an Ubuntu 18.04 Droplet.

Hope that this helps! Regards, Bobby

For all who made all the changes and still not working, try to upgrade PHP to 7.2.

Works for me.

I just want to contribute to this thread by stating that I too was seeing the same error message after switching my WordPress (PHP) droplet from a local db to a DO managed db. I had no trouble connecting to the managed db using mysql at the command line, but WordPress could not connect. I tried the ALTER USER command mentioned by @bobbyiliev, but it didn’t help. I noticed a couple of people in this thread suggested upgrading to PHP 7.2. My droplet was running Ubuntu 16.04 (PHP 7.0) so I decided to upgrade to Ubuntu 18.04 (PHP 7.2). That solved the problem! Note that it is still necessary to use the ALTER USER command @bobbyiliev mentioned, but once you do that on PHP 7.2 the managed db connection works fine.

Bottom line: It appears that only PHP 7.2 and above is compatible with MySQL 8.0 (the version currently used by DO’s managed MySQL dbs).

I have tried pretty much everything on this page. Still same error. Interestingly enough I even used a none existing user in the connection string to see if it was even making that far and it is not. It still says returns “The server requested authentication method unknown to the client”

I did try messing with the port, etc. just to make sure it was not on my end and got the errors that I expected.

I can connect fine from Navicat and verified everything…

mysql> select user,plugin,host from mysql.user where user='test_user';
| user      | plugin                | host |
| test_user | mysql_native_password | %    |
1 row in set (0.08 sec)

However when I try to connect with the following I still get the problem…

$vars['db_host']    = '';
$vars['db_user']    = 'test_user';
$vars['db_pass']    = 'password';

$conn = new mysqli($vars['db_host'], $vars['db_user'], $vars['db_pass'] );

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
echo "Connected successfully";

I am actually a little surprised that DO decided to go with the “new” default from MySQL 8, that very little actually supports yet, versus the standard that most already use. At the very least they should have an option at the server level versus the user level. Tons of people having the problem, after searching. (not exclusive to DO)