As the name of the error "Error Establishing Database Connection" suggests that your WordPress site is not able to connect to your database. There may be many reasons for this error. We will discuss all the main reasons which are responsible for this error. This error is normally occurred by one of the following main reasons:
The login credentials in the wp-config.php file do not match with the database login credentials.For your WordPress website to work correctly, Make sure that the login credentials in the wp-config file should match with the database login credentials. If they do not match, your WordPress site will not be able to connect to your database and your website will display this error message. The most common reason for this issue is that we manually change the database password but forget to change in the wp-config.php file. So In order to fix this issue open wp-config.php file and type the same database credentials and then save the file.
The Database may be CorruptedAnother reason for this error could be your corrupted database. Sometimes faulty themes and plugins may corrupt the database. They actually change the content of the database in such a way that it no longer remains readable or usable by the WordPress site. There is no way you can fix the corrupted database. However, the only possible solution is that you can restore the backup of the database. If you do not have the backup of your database then you can contact your hosting provider and they will help you to get the backup of your database.
The Database Does Not ExistIf the database is deleted accidentally from your hosting account then your WordPress website will display the same error because your website will not find any database to connect. The only solution is to restore your database. That's why it is highly recommended that you should take regular backups of your files and database. There are many free plugins available which keep saving the database in cloud storages like google drive, dropbox, etc
Database Server ErrorsSometimes this problem arises because of the database servers which are associated with your hosting. It may be because of heavy load on the server which makes databases unresponsive. This is a temporary problem from the hosting provider. You can contact your hosting provider in order to fix the problem. The problem may last from few minutes to few hours.
You can find more information regarding this error by going to WordPress.org.