An error establishing database connection is a fatal error that enables the users to access your website. Whenever WordPress is unable to create a connection with the database then you will get to see this type of error on the website. You can fix the following things to remove this error on the website:
·Check Your Database Credentials: This is the common reason for database connection error. Whenever you change your WordPress to a new host make sure to check and configure the database credentials.
·Check Your Database Host Information: Several times the system gets confused between the database host information. If you have correctly entered all the credentials and still your WordPress is not working then there might be a problem with the host information. For this, you need to contact your WordPress hosting company to Check the database host information.
·Repair WordPress Database: you can also Repair your WordPress Database to fix a database connection error.