Error Establishing Database Connection is a WordPress error that indicated that there’s an issue in connecting to the MySQL database.
Causes: Corrupt database; Wrong database connection credentials; Hosting server MySQL errors.
Fix 1
Make sure the wp-config.php file is connected to the correct database.
Fix 2
Go to cPanel > MySQL Databases, and make sure the Database User is added to the Database with Full User Permissions.
Fix 3
Change MySQL Password in cPanel > MySQL Databases, and replace the credentials in the wp-config.php file. If this happened after a migration, make sure the database host is set to localhost, like a default WordPress installation.
Like all technical areas, errors will happen. It’s important to note a few things regarding using the fixes in this article:
- Check DNS & make sure everything is proper before resorting to changing files.
- When handling any files, make sure to follow this guide: How to handle WordPress files