Joomla 2.5 utilizes a database to store a majority of a site's content. For example, if you write a new article in Joomla, the article is written to the database. As the database is vital for Joomla to run, if Joomla cannot connect to your database and access information, you will see database related error messages on your site. In this article, we'll show you a few common errors and how you can resolve them.

Common Joomla 2.5 Database Connection Error Messages:

Database connection error (2): Could not connect to MySQL.

database-connection-error-2-could-not-connect-to-mysql

Problem:
This error message generally means that your Joomla's configuration.php file has either the wrong database name or database username. In our testing environment, we changed both the database username and password, and in each separate occasion the same error message occurred.

Solution:
You should review your configuration.php file and ensure you are using the correct MySQL username and password. These settings will appear in the file as:

public $user = 'userna5_dbuser';
public $password = 'dbpass';

If you are sure the settings are correct, it is recommend to reset your database user's password and update your configuration.php file with the new password. This will help ensure that you have the correct database password set.

Database connection error (3): Could not connect to database

database-connection-error-3-could-not-connnect-to-database

Problem:
This error message usually means that you are connecting to the wrong database server. For most Joomla installations, the joomla files themselves and the database it connects to are on the same server. When this is the case, "localhost" should be used the database server. We recreated this error message by setting the database host to "localhosttt" (localhost spelled wrong).

Solution:
If your Joomla site is setup like most, check your configuration.php file and ensure your database host is set to "localhost". This is setting looks like the following in your config file:

public $host = 'localhost';

MySQL server has gone away

mysql-server-has-gone-away

Problem:
The "MySQL server has gone away" error generally means that there is a problem with MySQL on the server, therefor it is unavailable for use. In our testing environment, we shut down MySQL and received such a warning.

Solution:
If you are not an InMotion Hosting customer, you should contact your current web hosting provider with the necessary details for more help with this. At InMotion Hosting, we monitor our servers 24 hours a day. If MySQL is not functioning on a server, we are aware usually seconds after the issue occurs. You can rest assured we are on top of the problem and that it should be corrected shortly. As always, you can contact our Support Team if you desire to report such a problem.

Most often, if Joomla has been working fine and suddenly stops working due to a database error, there is a problem with the database on your server. You'll want to contact your hosting provider for further assistance. If you have recently made a change to Joomla and then you begin to see database errors, instead of contacting your host you should first check your database settings in your configuration.php file.

Continued Education in Course 212: Joomla 2.5 Advanced Database Information
You are viewing Section 4: Joomla database connection error (2): could not connect to mysql
Section 3: How to change your Joomla 2.5 database username and password
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 this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Joomla Community Google+ Hangout #3

June 3rd, 2014

Thank you @RustyJoomla for letting me speak on the Joomla Community Google+ Hangout!

Click here to watch!

2013-01-25 2:26 am
i had Database connection error (2): Could not connect to MySQL.
After following ur article it works...
Thank u sooo much n...Thanks a lot..
May God bless u with full grace..
n/a Points
2014-03-18 8:47 am

I'm very grateful because your site help-me. Thanks a lot.

n/a Points
2014-03-25 3:27 am

Thanks. Why this error comes even when there is no change in MySQL db.  The fact is that if you open the site ,It is opeing at first and then when I am refreshing it 3-4 times that error is coming. Plz help. You  can check the error at my site at www.lifeinglife.com    Thanks in advance

Staff
9,384 Points
2014-03-25 8:04 am
I was unable to produce any errors on your site so it appears to be just a previous intermittent issue that is now resolved.
n/a Points
2014-04-13 4:26 pm

Very useful and resourceful, helped me save so much time figuring out the cause of the error..Thanks so so much..

Much appreciation:)

n/a Points
2014-06-13 10:12 am

Excelente, muchas gracias por la solución.

n/a Points
2014-06-18 12:30 pm

please help

www.edibledesignimages.com

Database connection error (2): Could not connect to MySQL.

Staff
17,716 Points
2014-06-18 1:32 pm
Hello Carolina,

I'm sorry to hear you're having problems with connecting to your Joomla database. Unfortunately, you have given us no details with which to help you. Have you at least gone through the steps above and checked to see that the correct user name and password are being used for the database. One way to check is to use the database program that comes with your hosting. Since it doesn't appear that you're hosted with our service, we can't really check from here. You can reference our article on connecting to a database with MySQL workbench for further information on testing (using a different program).

I hope this helps give you at least a starting point. If you wish for us to investigate the issue further, we need further information on how you're connecting to the database.

Regards,
Arnel C.
n/a Points
2014-07-21 5:18 am

I'm very grateful because your site help-me. Thanks a lot. May Allah bless u with full grace

n/a Points
2014-09-03 3:24 am

Database connection error (2): Could not connect to MySQL. my joomla website was working very fine but after i have inserted the module for cintact suddely it started to show me that it cant connect to the database.....izt a module or server it self

Staff
10,207 Points
2014-09-03 11:28 am
Hello Maanda,

Thank you for your question. This could be caused by an issue with your server's services, or a misconfiguration of your database settings.

I first recommend reading our detailed guide database connection errors.

We would be happy to further assist you, but will need additional information such as the domain name of the site, and a link to the error message.

If you have any further questions, feel free to post them below.

Thank you,
John-Paul
n/a Points
2014-09-04 12:22 pm

Hey guys, thats for the page it's been really usefule although  I've tried to follow the steps which are great but when I click on the link reviewing the php file and it asks me to go to the administrator page I get the same SQL error as I do on my homepage which means I can't access the admin section to correct the configuration.php content. Any ideas?

URL: http://www.mixedmartialartsden.com/

 

Thanks a lot,

 

Victor

Staff
9,384 Points
2014-09-04 12:31 pm
To adjust the configuration.php file, you would do so within the cPanel File Manager which is available without any access to the Joomla Administration panel.

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

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

14 Questions & Comments

Post a comment

Back to first comment | top

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!