There is a database error on my website

One of the following errors is displayed:

  • “Error Establishing a Database Connection”;
  • “Database connection error (2): Could not connect to MySQL”
  • “DB error”;
  • “Could not connect to MySQL”;
  • “Could not connect to database”.

There are two main causes of this problem:

Incorrect credentials for database connections

  1. open your website’s configuration file, which contains database connection credentials. You can find out its location following the instructions: Were does the CMS store database connection settings
  2. the database server must be defined as ‘localhost’ (NOT 127.0.0.1), unless you are using a remote database on another server;
  3. refresh the database password. To do so, copy the password as specified in your configuration file (this is the file that you opened on the first step of this manual) and set it as a password for a new database user: How to change database user password.
  4. Clear your browser’s cache and check your website accessibility . To clear the cache, press ‘Ctrl’ + ‘F5’ or ‘Ctrl’ + ‘R’.

A table is damaged in the database

In the error description on the website you can see the text “Table was marked as crashed and should be repaired”. If that’s the case, the fastest way to resolve the issue would be to restore the database from backup.