It is a common issue and one that is actually part of running modern WordPress built website to have Errors connecting to databases. WordPress is a dynamic content management system that resides in a Database (usually MySQL) and there are many different ways you can troubleshoot Errors when establishing a Database Connection for websites built on WordPress.
First Step for Fixing Database Connection Errors
Realize that more often than not, this error has nothing to do with your WordPress site but rather the web hosting service you are using may be down temporarily (e.g. server reboot, maintenance or upgrade). That means first thing we should do is double check if the MySQL server is up and operating normally and that you can login to phpMyAdmin.
To check this, simply login to your web hosting and find cPanel. Look for DATABASES and Press on phpMyAdmin. You should be able to login to your Database where your WordPress installation resides in.
Check MySQL in cPanel
Simply browse in to your MySQL Database options to see if your Database WordPress is built upon is visible. Then explore database user options and password, you should see both the Database Name and the User of that Database.
Default WordPress configuration file named wp-config.php contains information for connecting to Database. Check to see if everything matches with your installation.
Other Database Connection Errors You May Encounter for WordPress
If you are not able to login to MySQL server using phpMyAdmin and get funny messages such as Error: 2002 CR_CONNECTION_ERROR. Then, its best that you first contact your web hosting provider to resolve the matter. Or perhaps visit MySQL Client Error Codes and Messages section.
How to Fix Error Establishing a Database Connection in WordPress Video Lesson
Once again, database connection errors are usually normal for a short period of time, if you’ve followed all the troubleshooting procedures and you still see Error Establishing a Database Connection Message in your internet browser. Then, triple check any plugins connecting to your database (disable any new plugin you installed), check Database User privileges or contact your web hosting provider as they will be able to assist you further.
Is your business website ready for 2022? Get top Google rankings and website conversions. Here's howMaster Class ☄ 100% Good URLs ☄