Question

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.

Bobby Iliev
Site Moderator
Site Moderator badge
August 23, 2019
Accepted Answer

Hello,

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).

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.