New managed DB user can only authenticate from app if previously authenticated using mysql client CLI

Posted April 22, 2021 164 views

I’ve had this problem with every application I’ve deployed which uses a DO Managed MySQL database.

  1. Create DB user through MySQL shell
  2. PHP 7.4 application cannot authenticate using the credentials
  3. Connect to DB using MySQL client CLI
  4. Now my application can connect

The error I get in the application is:

An exception occurred in driver: SQLSTATE[HY000] [1045] Access denied for user ’{{user here}}’@’{{ IP here }}’ (using password: YES)

If I ever add a new DB user and FLUSH PRIVILEGES it breaks any applications that use the DB. I have to repeat step 3 above to get them working again.

Does anyone know what is going on? It is becoming a real problem for me.

Submit an answer

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