Problem
Are you seeing the ‘Error establishing a database connection’ notice on your WordPress website? It is a fatal error that makes your WordPress website inaccessible to the users.
This error occurs when WordPress is unable to make a connection to the database. A number of things can affect your WordPress database connection which makes it a bit difficult for beginners to troubleshoot.
Solution
Check Point 1 - Check Your Database Credentials
Check Point 2 - Check Your Database Host Information
Check Point 3 - Check If Your Database Hasn’t Been Corrupted
You need to make sure that the information prodived for your appplications is correct, including the database name, username, password, and database host.
To check it, we can use ssh
to access the physical machine or any virtual containers that runs your MySQL instance and use the following to check whether we can connect to MySQL manually?
1 | $ mysql -u root -p |
Potential Error
1 | $ mysql -u root -p |