WordPress Error Establishing Database Connection

Solution:1

One other scenario that causes this is due to Mysql8 users that are not set to have native password. You may have to do something as simple as

 

ALTER USER ‘jeffrey’@’localhost’

  IDENTIFIED WITH mysql_native_password

             BY ‘password’;

and this will fix the issue. Just ran into it with a fresh WP install, and could not figure out why the credentials looked correct, but WP would keep saying it could not connect. Finally enabled debug:

 

define( ‘WP_DEBUG’, true );

define( ‘WP_DEBUG_DISPLAY’, true );

and this showed the actual error that was happening: “The server requested authentication method unknown to the client”.

 

Hope this helps someone!

Solution:2

Add 127.0.0.7:3307 port in database host instead of localhost and MySQL port 3307 or your MySQL port no. after database host

Solution:3

 Error Establishing Database Connection usually mean your database login details on wp-config.php are incorrect