Database connection error (2): Could not connect to MySQL.
Moderator: General Support Moderators
Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
-
- Joomla! Apprentice
- Posts: 9
- Joined: Tue Sep 17, 2013 10:39 pm
Database connection error (2): Could not connect to MySQL.
Hi everyone, first post here.
I started building a Joomla website for the first time yesterday and everything was going well until today I was suddenly unable to access my website. Whenever I try to access it I just see a blank screen and a message that reads 'Database connection error (2): Could not connect to MySQL.'
The website is hosted with godaddy.com so I called them. First, they told me to try and clear my computer's cache to see if that would have any effect. It didn't, so afterwards I called them again and they told me that it's probably some problem with one of the files in the database but they wouldn't know how to fix it.
I've read suggestions online that say that people with this problem should go to the backend of their website and access the configuration.php file. I don't know what this is or how to get to it because I can't access my /administrator page.
If anyone can help me with this it would be hugely appreciated!
I started building a Joomla website for the first time yesterday and everything was going well until today I was suddenly unable to access my website. Whenever I try to access it I just see a blank screen and a message that reads 'Database connection error (2): Could not connect to MySQL.'
The website is hosted with godaddy.com so I called them. First, they told me to try and clear my computer's cache to see if that would have any effect. It didn't, so afterwards I called them again and they told me that it's probably some problem with one of the files in the database but they wouldn't know how to fix it.
I've read suggestions online that say that people with this problem should go to the backend of their website and access the configuration.php file. I don't know what this is or how to get to it because I can't access my /administrator page.
If anyone can help me with this it would be hugely appreciated!
- pe7er
- Joomla! Master
- Posts: 22352
- Joined: Thu Aug 18, 2005 8:55 pm
- Location: Nijmegen, The Netherlands
- Contact:
Re: Database connection error (2): Could not connect to MySQ
Welcome to Joomla forum!UnderwaterN0w wrote:today I was suddenly unable to access my website. Whenever I try to access it I just see a blank screen and a message that reads 'Database connection error (2): Could not connect to MySQL.'
You have to check and maybe change your database credentials,
see http://docs.joomla.org/Unable_to_connec ... e_database
You can use FTP (e.g. FileZilla) to access the files of your Joomla website.UnderwaterN0w wrote:the configuration.php file. I don't know what this is or how to get to it because I can't access my /administrator page.
Joomla's configuration.php should be in the root of your website (in a folder probably called www, public_html, htdocs)
Kind Regards,
Peter Martin, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
Co-developer of d2 Content https://data2site.com/joomla-extensions/d2-content
Peter Martin, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
Co-developer of d2 Content https://data2site.com/joomla-extensions/d2-content
-
- Joomla! Apprentice
- Posts: 9
- Joined: Tue Sep 17, 2013 10:39 pm
Re: Database connection error (2): Could not connect to MySQ
Thanks for the quick reply, pe7er.pe7er wrote:Welcome to Joomla forum!UnderwaterN0w wrote:today I was suddenly unable to access my website. Whenever I try to access it I just see a blank screen and a message that reads 'Database connection error (2): Could not connect to MySQL.'
You have to check and maybe change your database credentials,
see http://docs.joomla.org/Unable_to_connec ... e_database
You can use FTP (e.g. FileZilla) to access the files of your Joomla website.UnderwaterN0w wrote:the configuration.php file. I don't know what this is or how to get to it because I can't access my /administrator page.
Joomla's configuration.php should be in the root of your website (in a folder probably called www, public_html, htdocs)
I just installed FileZilla and tried to logon to Joomla using my admin login account and password but when I try it says
'Response: 530 Login authentication failed
Error: Critical error
Error: Could not connect to server'
Any idea why this is?
- pe7er
- Joomla! Master
- Posts: 22352
- Joined: Thu Aug 18, 2005 8:55 pm
- Location: Nijmegen, The Netherlands
- Contact:
Re: Database connection error (2): Could not connect to MySQ
Yes, your Joomla user + password = for login into Joomla only.UnderwaterN0w wrote:I just installed FileZilla and tried to logon to Joomla using my admin login account and password but when I try it says
'Response: 530 Login authentication failed
Error: Critical error
Error: Could not connect to server'
Any idea why this is?
For FTP you'll have a different username + password.
Kind Regards,
Peter Martin, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
Co-developer of d2 Content https://data2site.com/joomla-extensions/d2-content
Peter Martin, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
Co-developer of d2 Content https://data2site.com/joomla-extensions/d2-content
-
- Joomla! Apprentice
- Posts: 9
- Joined: Tue Sep 17, 2013 10:39 pm
Re: Database connection error (2): Could not connect to MySQ
Okay, so what username + password are we talking about? I've also tried to use the ones for my hosting company and the ones for my website's database but either of them worked.pe7er wrote:Yes, your Joomla user + password = for login into Joomla only.UnderwaterN0w wrote:I just installed FileZilla and tried to logon to Joomla using my admin login account and password but when I try it says
'Response: 530 Login authentication failed
Error: Critical error
Error: Could not connect to server'
Any idea why this is?
For FTP you'll have a different username + password.
Is there a separate FTP username + password that I need to activate?
As you can probably tell, this is the first time I've ever used a FTP so please be patient with me.

- pe7er
- Joomla! Master
- Posts: 22352
- Joined: Thu Aug 18, 2005 8:55 pm
- Location: Nijmegen, The Netherlands
- Contact:
Re: Database connection error (2): Could not connect to MySQ
In your hosting panel (cpanel / direct admin / or something else) there might be an option to create FTP users or change FTP password.UnderwaterN0w wrote: Okay, so what username + password are we talking about? I've also tried to use the ones for my hosting company and the ones for my website's database but either of them worked.
Depends on your hosting company.UnderwaterN0w wrote:Is there a separate FTP username + password that I need to activate?
At some providers you have to enable FTP & create a FTP user + FTP password.
Other providers create it automatically & send you the details in their welcome mail.
No worries! We have all been thereUnderwaterN0w wrote:As you can probably tell, this is the first time I've ever used a FTP so please be patient with me.

Kind Regards,
Peter Martin, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
Co-developer of d2 Content https://data2site.com/joomla-extensions/d2-content
Peter Martin, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
Co-developer of d2 Content https://data2site.com/joomla-extensions/d2-content
-
- Joomla! Apprentice
- Posts: 9
- Joined: Tue Sep 17, 2013 10:39 pm
Re: Database connection error (2): Could not connect to MySQ
Thanks a lot, I managed to find my FTP username and password and I found my configuration.php file.pe7er wrote:In your hosting panel (cpanel / direct admin / or something else) there might be an option to create FTP users or change FTP password.UnderwaterN0w wrote: Okay, so what username + password are we talking about? I've also tried to use the ones for my hosting company and the ones for my website's database but either of them worked.
Depends on your hosting company.UnderwaterN0w wrote:Is there a separate FTP username + password that I need to activate?
At some providers you have to enable FTP & create a FTP user + FTP password.
Other providers create it automatically & send you the details in their welcome mail.
No worries! We have all been thereUnderwaterN0w wrote:As you can probably tell, this is the first time I've ever used a FTP so please be patient with me.
In the link you sent me above it said that the normal database settings are:
var $dbtype = 'mysql';
var $host = 'localhost';
var $user = 'user_with_database_access';
var $db = 'the_actual_database_name';
var $dbprefix = 'table_prefix_';
I have a few questions:
1. Instead of starting with 'var' (what does this stand for?), my database settings start with 'public' - is that correct?
2. For my $host it says '*database name*. db.*some numbers*.hostedresource.com' - is this OK?
3. For my $user it has my database account, not my Joomla admin one - is this OK?
4. My $password appears as a seemingly random combination of letters, symbols and numbers rather than the password I created for the database - is this just the way the system interprets my password or is this a mistake?
5. How do I find out what my $dbprefix should be?
Many thanks in advance!
- pe7er
- Joomla! Master
- Posts: 22352
- Joined: Thu Aug 18, 2005 8:55 pm
- Location: Nijmegen, The Netherlands
- Contact:
Re: Database connection error (2): Could not connect to MySQ
Yes, in J2.5 it starts indeed with 'public'.UnderwaterN0w wrote:1. Instead of starting with 'var' (what does this stand for?), my database settings start with 'public' - is that correct?
This setting depends on your host, but I guess that it looks correct.UnderwaterN0w wrote:2. For my $host it says '*database name*. db.*some numbers*.hostedresource.com' - is this OK?
Yes, because the configuration.php is for Joomla to access the database.UnderwaterN0w wrote:3. For my $user it has my database account, not my Joomla admin one - is this OK?
The password should be the plain text password. If it's not the password you created for the database, then this would probably be why Joomla could not connect to the database.UnderwaterN0w wrote:4. My $password appears as a seemingly random combination of letters, symbols and numbers rather than the password I created for the database - is this just the way the system interprets my password or is this a mistake?
with phpMyAdmin you can see all the database tables of your Joomla site, including their prefix..UnderwaterN0w wrote:5. How do I find out what my $dbprefix should be?
Kind Regards,
Peter Martin, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
Co-developer of d2 Content https://data2site.com/joomla-extensions/d2-content
Peter Martin, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
Co-developer of d2 Content https://data2site.com/joomla-extensions/d2-content
-
- Joomla! Apprentice
- Posts: 9
- Joined: Tue Sep 17, 2013 10:39 pm
Re: Database connection error (2): Could not connect to MySQ
OK, I tried to edit the password to make it the correct one, but whenever I try to upload the new configuration.php file it won't let me:pe7er wrote: The password should be the plain text password. If it's not the password you created for the database, then this would probably be why Joomla could not connect to the database.
Response: 227 Entering Passive Mode (*numbers*)
Command: STOR configuration.php
Response: 553 Can't open that file: Permission denied
Error: Critical file transfer error
Status: Disconnected from server
Error: Connection closed by server
What should I do?
Last edited by UnderwaterN0w on Fri Sep 20, 2013 3:49 pm, edited 1 time in total.
- leolam
- Joomla! Master
- Posts: 19767
- Joined: Mon Aug 29, 2005 10:17 am
- Location: Netherlands/ UK/ S'pore/Jakarta/ North America
- Contact:
Re: Database connection error (2): Could not connect to MySQ
change with ftp the permissions from the configuration.php file to 644 and save againUnderwaterN0w wrote:What should I do?
Leo

Joomla's #1 Professional Support Provider:
-> Joomla Professional Support: https://gws-desk.com -
-> Joomla Specialized Hosting Solutions: https://gws-host.com -
-> Joomla Webmaster Services: gws-webmaster.services
-> Joomla Professional Support: https://gws-desk.com -
-> Joomla Specialized Hosting Solutions: https://gws-host.com -
-> Joomla Webmaster Services: gws-webmaster.services
-
- Joomla! Apprentice
- Posts: 9
- Joined: Tue Sep 17, 2013 10:39 pm
Re: Database connection error (2): Could not connect to MySQ
Thank you! I can now finally see my website's content again.leolam wrote:change with ftp the permissions from the configuration.php file to 644 and save againUnderwaterN0w wrote:What should I do?
Leo

The only problem is that my original Joomla admin account + password don't seem to work anymore and so I can't edit my website...
A couple of days ago I noticed on my database that under jos_users the Super Admin's password was a weird set of numbers, letters and symbols and not my actual password, so I changed it to my real (plain text) password.
Could that be the cause of the problem?
- leolam
- Joomla! Master
- Posts: 19767
- Joined: Mon Aug 29, 2005 10:17 am
- Location: Netherlands/ UK/ S'pore/Jakarta/ North America
- Contact:
Re: Database connection error (2): Could not connect to MySQ
You cannot do that. The serial you see in jos_users is a MD5 Hashed (encrypted) password so you have perfectly mashed up the access to wet potatoesUnderwaterN0w wrote:A couple of days ago I noticed on my database that under jos_users the Super Admin's password was a weird set of numbers, letters and symbols and not my actual password, so I changed it to my real (plain text) password.
So here is what you do: http://docs.joomla.org/How_do_you_recov ... assword%3F and scroll down to "direct Editing of Database" and follow these steps outlined. Once done you login and you change in administrator panes the user password to something strong! http://forum.joomla.org/viewtopic.php?t=799242
Than install Admin Tools of Akeebabackup.com (free) and change the jos_ prefix to something different. Using jos_ is a high security risk!
Leo

Joomla's #1 Professional Support Provider:
-> Joomla Professional Support: https://gws-desk.com -
-> Joomla Specialized Hosting Solutions: https://gws-host.com -
-> Joomla Webmaster Services: gws-webmaster.services
-> Joomla Professional Support: https://gws-desk.com -
-> Joomla Specialized Hosting Solutions: https://gws-host.com -
-> Joomla Webmaster Services: gws-webmaster.services
-
- Joomla! Apprentice
- Posts: 9
- Joined: Tue Sep 17, 2013 10:39 pm
Re: Database connection error (2): Could not connect to MySQ
Hi Leo,leolam wrote:You cannot do that. The serial you see in jos_users is a MD5 Hashed (encrypted) password so you have perfectly mashed up the access to wet potatoes
So here is what you do: http://docs.joomla.org/How_do_you_recov ... assword%3F and scroll down to "direct Editing of Database" and follow these steps outlined. Once done you login and you change in administrator panes the user password to something strong! http://forum.joomla.org/viewtopic.php?t=799242
Than install Admin Tools of Akeebabackup.com (free) and change the jos_ prefix to something different. Using jos_ is a high security risk!
Leo
I tried to directly change the password to my database to the value that was given in the instructions you linked but it didn't work. I couldn't login to my admin page with the my old username and this new password.
In the instructions it says: A form will display that allows you to edit the password field. Copy the value into the password field and press the Go button. phpMyAdmin should display the message "Affected rows: 1". At this point, the password should be changed to "secret".
I didn't know how to change the new password to "secret". How do I do this? Could this be why the new password wasn't working?
Also, out of interest, why is running a database with the jos_ prefix considered a high security risk?
- pe7er
- Joomla! Master
- Posts: 22352
- Joined: Thu Aug 18, 2005 8:55 pm
- Location: Nijmegen, The Netherlands
- Contact:
Re: Database connection error (2): Could not connect to MySQ
If any of your 3rd party extensions has a security issue, then a cracker will try to add a new super admin to your website by running an SQL insert query.UnderwaterN0w wrote:Also, out of interest, why is running a database with the jos_ prefix considered a high security risk?
For that you'll have to specify the #__users table.
As jos_ is a common prefix, they will try that first.
They would have a lot more difficulty trying all other combinations of letters....
Kind Regards,
Peter Martin, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
Co-developer of d2 Content https://data2site.com/joomla-extensions/d2-content
Peter Martin, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
Co-developer of d2 Content https://data2site.com/joomla-extensions/d2-content
- leolam
- Joomla! Master
- Posts: 19767
- Joined: Mon Aug 29, 2005 10:17 am
- Location: Netherlands/ UK/ S'pore/Jakarta/ North America
- Contact:
Re: Database connection error (2): Could not connect to MySQ
You enter that value and hit the "go" button in phpMyAdmin. Than you can login with your username and password "secret". To make sure you hit the "truncate" button in the jos_session table (empty it but NOT delete!)UnderwaterN0w wrote:I tried to directly change the password to my database to the value that was given in the instructions you linked but it didn't work. I couldn't login to my admin page with the my old username and this new password.
If if than does not work you might need to hire somebody to have a look for you and resolve it since you are lacking sufficient knowledge (no offense but just an observation)
Leo

Joomla's #1 Professional Support Provider:
-> Joomla Professional Support: https://gws-desk.com -
-> Joomla Specialized Hosting Solutions: https://gws-host.com -
-> Joomla Webmaster Services: gws-webmaster.services
-> Joomla Professional Support: https://gws-desk.com -
-> Joomla Specialized Hosting Solutions: https://gws-host.com -
-> Joomla Webmaster Services: gws-webmaster.services
-
- Joomla! Apprentice
- Posts: 9
- Joined: Tue Sep 17, 2013 10:39 pm
Re: Database connection error (2): Could not connect to MySQ
I understand. So how do I go about changing my database to another prefix?pe7er wrote:If any of your 3rd party extensions has a security issue, then a cracker will try to add a new super admin to your website by running an SQL insert query.UnderwaterN0w wrote:Also, out of interest, why is running a database with the jos_ prefix considered a high security risk?
For that you'll have to specify the #__users table.
As jos_ is a common prefix, they will try that first.
They would have a lot more difficulty trying all other combinations of letters....
-
- Joomla! Apprentice
- Posts: 9
- Joined: Tue Sep 17, 2013 10:39 pm
Re: Database connection error (2): Could not connect to MySQ
By the way, I finally managed to fix the problem!
Thank you, pe7er and Leo, for all your help. I am enormously grateful because now I can finally get back to editing my website.
It's fair to say that my first impressions of the Joomla community have been very positive!

Thank you, pe7er and Leo, for all your help. I am enormously grateful because now I can finally get back to editing my website.

It's fair to say that my first impressions of the Joomla community have been very positive!
- leolam
- Joomla! Master
- Posts: 19767
- Joined: Mon Aug 29, 2005 10:17 am
- Location: Netherlands/ UK/ S'pore/Jakarta/ North America
- Contact:
Re: Database connection error (2): Could not connect to MySQ
For these kinds of changes (i.e database prefix etc install Akeebabackup.com's AdminTools. This will do this for you and is free. Does a lot more positive things so check it out!
Leo
Leo

Joomla's #1 Professional Support Provider:
-> Joomla Professional Support: https://gws-desk.com -
-> Joomla Specialized Hosting Solutions: https://gws-host.com -
-> Joomla Webmaster Services: gws-webmaster.services
-> Joomla Professional Support: https://gws-desk.com -
-> Joomla Specialized Hosting Solutions: https://gws-host.com -
-> Joomla Webmaster Services: gws-webmaster.services
-
- Joomla! Fledgling
- Posts: 1
- Joined: Fri May 16, 2014 2:15 am
- Location: New Hampshire, USA