Getting a database connection error, such as this one in Joomla, can be a scary thing to see on your website. It means that a program running on your site is not able to communicate with the MySQL database service to retrieve data. There are two main reasons for getting this error, either the program itself is not connecting properly due to login credentials mismatch from the program's configuration files, or the MySQL service is currently not running on the server. Below are instructions on how to check both.

Checking Program Configuration Files

If you have recently installed your program or changed the configuration options in the program, you will want to check to ensure the configuration files match what the database is expecting. The credentials you will need to know are the database name, host, database user name, and the database password.

First you will want to find these credentials in your program's configuration files. If you are unsure where these files are located for your program, you can check to see if the program is listed in our configuration files list article. Be sure to write down all the database credentials you find as you will need to check them against the server.

Once you have the credentials from the connecting program, you will need to check them against the server to make sure they are the same. The steps below will guide you on doing that.

  1. Log into your cPanel
  2. Locate the Databases category and click on the MySQL Databases icon.
  3. From the databases page you will see your databases in a list along with the database user in the column next to it.
  4. After confirming the database name and username, you will want to confirm the password. Since you cannot see the password, you will need to reset it by deleting the user and then recreating and attaching it to the database using the password from the configuration file.

Telnet Test

If you have confirmed the credentials and are still getting the error, or the program was working and the database connection error suddenly began, it is possible the MySQL service is not running on the server at the moment. You can test this by running a test with something called Telnet. Telnet is a network protocol that you can use to connect to the server directly and check the service availability. Below are the steps to running a test with Telnet.

Note that newer versions of Windows do not have the Telnet service enabled by default. You may have to enable it before running this test. You can find instructions on how to do this in our article on enabling telnet on a Windows computer.
  1. Log into your command line interface. With a Windows machine you go to Start -> Run -> cmd. With Mac, you will need to open your Terminal application.
  2. Once in the command line interface, you will type the command telnet example.com 3306. (be sure to replace example.com with your own domain name). Here is the breakdown of the command: telnet is the command to tell the computer to use the telnet protocol. The domain name is telling which domain name/server to connect to, and the 3306 is the port for the MySQL service it will test. Below is an example of how your command should appear.

    telnet example.com 3306
  3. Hit the enter key to activate the command. It will connect to the server using Telnet and test the port. If it is running, you will get a confirmation string beginning with the MySQL database version number.

    5.1.66-c115btB+Q...

    If the MySQL service is not running, you will receive an error as below:
    Connecting to example.com...Could not open connection to the host, on port 3306: Connect failed.

If you receive the connection failed error, the likely causes of service unavailability are either a temporary high load on the server, or the service is being restarted by the Systems Administration team. This should clear up within a few minutes. If you receive the connection confirmation and are still receiving the error, you will want to contact our Live Support team for further assistance.

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve our Support Center:
Email Address
Optional, but our team may contact you for more information.
Like this Article?

Post a Comment

Name:
Email Address:
Comment:
Are you a bot?
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

Write New!
Do you want to publish a tutorial to our support center?

News / Announcements

SSL Certficate Warnings
Updated 2014-04-14 11:34 am EST
Hits: 2220
Heartbleed 0-day OpenSSL security bug
Updated 2014-04-14 04:43 pm EST
Hits: 5641

Related Questions

Here are a few questions related to this article that our customers have asked:
Database connection error (2): Could not connect to MySQL
joomla- Database connection error (2): Could not connect to MySQL
Why does the mysql database keep disconnecting?
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!