Error Establishing a Database Connection
This error means that WordPress is unable to connect to its database. It's usually caused by incorrect credentials, database corruption, or a temporary server-side issue. Follow the troubleshooting steps below to identify and resolve the problem.
1. Verify the database credentials in wp-config.php
Start by checking the credentials stored in your WordPress configuration file.
- Log in to your OS Cloud panel.
- Go to the Websites section, select your website, and open the File Manager.
- Navigate to your WordPress root directory (usually
/public_html/). - Open the
wp-config.phpfile for editing. You'll find entries like this:
define('DB_NAME', 'your_database_name');
define('DB_USER', 'your_database_user');
define('DB_PASSWORD', 'your_database_password');
define('DB_HOST', 'localhost');2. Verify the database details in the panel
Once you've reviewed the credentials in wp-config.php, make sure they match the actual database details in the panel.
- In the panel, go to your website and select Databases.
- Confirm that the values for
DB_NAME,DB_USER, andDB_PASSWORDinwp-config.phpmatch an existing database in the list.
If any of these details don't match, update them in wp-config.php to reflect the correct database name and user.
Tip: You can also create new database users under the Database users section if needed.
3. Reset the MySQL user password
If the database details look correct, the issue is most likely the password. In that case, reset the MySQL user's password and update it in wp-config.php.
- Go back to the Database users section.
- Select the user whose password you want to change.
\
- Click Reset in the top-right of the block and enter a new password in the input field.
- Click Change password to confirm. Then update the
DB_PASSWORDvalue in yourwp-config.phpfile with the new password.
4. Make sure the MySQL user has the right permissions
- Go back to the Database users section.
- Select the user whose privileges you want to edit.
- Scroll down to the Database access section.
- Click the kebab menu (three vertical dots) on the right and select Edit privileges.
- Tick the box All database privileges.
- Save your changes and exit.
This gives the MySQL user full access to the database, ensuring WordPress can connect and function correctly.
