Error Establishing a Database Connection in WordPres

How to Fix the Error Establishing a Database Connection

Error Connecting to Database

This maybe one of the simplest error messages wordpress provides. The error message is clear that your website is unable to connect to the database. However solving this error can difficult if you are not familiar with your hosting server.

This error usually occurs when database details have been changed either database hostname, database username, and database password. Sometimes your database server is unresponsive, overloaded, or your database may have corrupted. You would be surprised with the amount of website owners that forget to pay for their hosting.

Most likely an incorrect database or overloaded mysql server.

Repairing your wordpress database.

You should check if the error is on both the front end(viewing website) of the site, and the back-end of the site (wp-admin/login panel). If the error is the same on both pages “Error establishing a database connection”, then proceed onto the next step.

If you are getting an error on the wp-admin for example “One or more database tables are unavailable”

The database needs to be repaired.

You can do this by adding the following line in your wp-config.php file, located at the root level of your wordpress install:


By changing false to true in your wp-config.php file . You will be able to repair your database by navigating to the following URL

Repair a corrupted wordpress database

Remember, the user does not need to be logged in to access the repair database, when this define is set to true. This is because the main reason is to repair a corrupted database.

Users usually cannot login when the database is corrupt.

Once you are done repairing and optimizing your database, remove this code from your wp-config.php.

Fix wordpress ftp password request

How to fix wordpress asking for password for every plugin install or update.


Simple fix to annoying problems with wordpress
If you are using ftp and have access to your wp-config file edit it.

Adding your server host address as your ftp host or visit find my website server ip address

With this address you are ready, if you know your ftp username and password.

If you dont know your ftp username and password talk to your hosting company

So, put the following code into you wp-config (i put it under /** The Database Collate type. Don’t change this if in doubt. */
define(‘DB_COLLATE’, ”);

Which is standard wordpress code) and it works

define(‘FTP_HOST’, ‘your-ip-address-here’);
define( ‘FTP_USER’, ‘jsos20’ );
define( ‘FTP_PASS’, ‘*************’ );

These hack are tried and tested on Pinguis Websites Design’s Websites.