How to fix the WordPress “Error Establishing Database Connection” problem

Solution 1:

Another possible cause is when MySQL 8 users are not configured with the native password plugin.

You can fix this by running:


ALTER USER 'jeffrey'@'localhost'
  IDENTIFIED WITH mysql_native_password
  BY 'password';

This resolves the issue. I encountered it during a fresh WordPress install—the credentials looked correct, but WordPress kept failing to connect.

Enabling debugging revealed the actual error:


<?php
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', true );
?>

The message was: “The server requested authentication method unknown to the client”.

This adjustment fixed the problem. Hopefully, it saves someone else the trouble!

Solution 2:

The error “Error Establishing Database Connection” usually indicates that the database login details in your wp-config.php file are incorrect. Double-check the database name, username, password, and host values.