I Have a Database Connection Error
A database connection error means that there is a program running on your site that cannot connect to or communicate with your MySQL database. Because it cannot retrieve the data that it needs to work correctly, it returns an error message.
There are several possible reasons why this could be happening. The following are some of them:
- You have incorrect login credentials.
- The MySQL is currently not active on the server.
- There are some corrupted data in your database.
- The entire database you need to access is corrupted.
You can check to see what the problem is and try to resolve the issues by running the following tests.
Check and Modify Your MySQL Configuration Settings
One reason that the program you are running may be unable to establish a connection with your database is that the username and/or password you are using may not match the configuration settings stored in the server.
If this is the case, you should make sure the configuration settings match by checking the username and its corresponding password. If you’re not certain that you remember the current password, you have the option to reset or change the password.
To check the username and be able to change your password, follow the steps below:
- Access your Hosting Manager.
- On the Home page, click the word Databases or the [ v ] arrow symbol. Then, click the MySQL Databasesoption.
- Under Current Users, check the username of the privileged user connected to the database you are trying to access.
- After confirming the database name and username, and if you can’t remember the password, you may reset it and create a new one. To do this, click Change Password or the key symbol to the right.
- On the next page, below the Set MySQL User Password, fill out the Password fields.
- Click Change Password to save your new password.
If you find it difficult to make a strong enough password for your email, you can let the system create one for you.
Click the Password Generator button. In the pop-up box, copy the generated password and paste that in the Password fields.
You can also choose to check I have copied this password in a safe place. Then, click Use Password. This will automatically copy and paste the generated password in the Password fields.
Important: Make sure you have actually saved the generated password in a safe and easy to recall place.
Congratulations, you now know how to check your database configuration settings and reset your password.
Check if MySQL is active
Another possibility that you are unable to establish a connection to the database is if it is deactivated. To check if your database is active or not, you can use the following:
- the phpinfo.php file
With the phpinfo.php page
To access the phpinfo.php, follow the steps below:
- Open a web browser tab.
- Type the file's web address (url) in the browser address bar. Usually, it can be found in the public_html/www directory. The URL will be http://yourdomain.com/phpinfo.php. Simply replace the “yourdomain.com” with your own domain name.
- If you typed in the correct path, the page should load and display all information about the configuration of your server. To get the information on MySQL, simply scroll down to get to the MySQL data tables.
By default, the tables will be arranged in alphabetical order.
If you don’t have a phpinfo.php page yet, you can create one in your File Manager. To know how to do this, click the link below:
To use Telnet to check if your MySQL database is activated, follow the steps below:
- With your Windows computer, access the Start menu.
- Next, go to Run, then type cmd to access command prompt.
If you are using Mac, go to Search on the upper right corner of your screen, and type "terminal". Click on the top search result and that should launch the terminal window on your Mac.
- Once inside the command line interface or terminal window, type the following command:
telnet yourdomain.com 3306Be sure to replace the "yourdomain.com" with your own domain name.
- Hit the Enter key on your keyboard. This will activate the command, test the port, and your computer will try to connect to your server through Telnet.
If your MySQL database is activated, you will get a confirmation string that will start with a MySQL database version number.
If your MySQL database is deactivated, you will receive the error message Could not open a connection to the host.
Note: There is also the possibility that the likely causes of service unavailability are either a temporary high load on the server, or the service is being restarted. This should clear up within minutes.
Check MySQL database
Yet another reason you may be having problems with your database is because some files or sections may be corrupted. To find out of this is the case, you need to run a system check on your database. To do this, follow the steps below:
- Access your Hosting Manager.
- On the Home page, click the word Databases or the [ v ] arrow symbol. Then, click the MySQL Databases option.
- Under Modify Databases, go to Check Database. Select the database you want to check, then click Check Database button to the right.
- The system will then run a script to check the database.
If the system detects an error, it will say so in the results page and will even specify where the corrupted files or sections can be found.
If the database has no problems, it will display gray box with list of sections with “OK” statuses and the phrase Check Complete in a green box at the bottom.
If the Check Database test returned some errors, you can try to resolve these by running “Repair Database”. Please visit our guide to learn How to fix a MySQL database.
Or, if you have a backup copy of your MySQL database, you may also restore your database to a previous version. If you are still unable to resolve the issue after a time, please contact us for further assistance. We’d be glad to help you!
Fantastic...Thank you for your feedback =)
Sorry... Please submit a support ticket or try another search.
Support ticket has been sent to your email, please check for your ticket id.
- Database Connection Error With WordPress
- Server Connection Timeout Error Explained
- Connection to Storage Server Failed Error Explained
- Create a new database & user with MySQL database wizard
- What is an SSH connection and what is it used for?