To Check your database login details in wp-config
How the database login details could have suddenly stopped working! Things like switching hosting companies or changing anything about your database name or user information could cause the error if your wp-config file wasn’t updated with the new information.
Log into your cPanel and open the File Manager. Look for a file called wp-config.php in the directory of installed WordPress. Then go ahead and open that for editing.
You’ll see the login credentials for your database, probably near the top of the file. It should look something like this:
define( 'DB_NAME' , 'database_name_here' ); |
define( 'DB_USER' , 'username_here' ); |
define( 'DB_PASSWORD' , 'password_here' ); |
define( 'DB_HOST' , 'localhost' ); |
As you can see, there are four lines of information WordPress needs to access your database:
- The name of the database (“DB_NAME”)
- The login username (“DB_USER”)
- The login password (“DB_PASSWORD”)
- The database host (“DB_HOST”)
If any of these values is incorrect, WordPress will not be able to connect to the database. Then it shows the Error “Error establishing a database connection”.