Wordpress: Error establishing a database connection - you can do that
Don't worry: If you suddenly get the message "Error establishing a database connection" when opening your WordPress website, you don't have to set up your website again. The error can be easily remedied with a little background knowledge. You can find out how to do this here.
WordPress database connection: database server failed
WordPress requires an SQL database to run smoothly in the background. If the connection cannot be established, you will only see an error message instead of your website.
- Sometimes there are short-term technical problems over which you have no control.
- Therefore, first check whether your host's database server is running at all.
- You can either call the hotline or check whether your provider publishes online fault reports.
- If you can rule out that the server is down, you have to check the connection information from WordPress to the database.
WordPress database connection: entries in wp-config incorrect
- Select yourself on your server using an FTP program and load the "wp-config.php" file from the root directory onto your computer.
- Open the file with Notepad or WordPad.
- Compare the following entries with the information you received from your provider and with your personal login data.
- define ('DB_NAME', 'The name of your database');
- define ('DB_USER', 'your database username');
- define ('DB_PASSWORD', 'your database password');
- define ('DB_HOST', 'The server address assigned by your provider');
- If entries do not match your data, correct them. Such errors often occur during a new WordPress installation or when you change the password of your existing website. Save the changes.
- Go back to your FTP program and rename the existing "wp-config.php" to "wp-config.php_old". So you always have a backup available should something go wrong with the change.
- Transfer the corrected file to the server. WordPress should now be able to connect to the database easily.
- If everything works, you can delete the backup "wp-config.php_old".
WordPress database connection: database is damaged
- Sometimes a connection may drop while data is being written. Part of the database is damaged.
- Providers usually provide the "phpMyAdmin" tool. Log in there. You can then select all the tables in the database and repair them using the "Repair table" option.
- A smart solution is the automatic repair of tables.
- You already know how to call up and change the "wp-config.php" file. Follow the steps described above.
- Enter the following line in this file: define ('WP_ALLOW_REPAIR', true);
- From now on, WordPress will automatically fix the tables for you and you will no longer have to worry about them.
WordPress database connection: database is empty or does not exist
- This problem mostly occurs if you change the provider and the old database has not yet been imported correctly.
- Log in to "phpMyAdmin" and check whether the database is available and has content.
- If the database does not exist or is empty, import the data from your backup again.
In the next article, read what exactly is behind WordPress permalinks.