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

Discussion regarding Joomla! 2.5 Performance issues.

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.
Locked
UnderwaterN0w
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Sep 17, 2013 10:39 pm

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

Post by UnderwaterN0w » Tue Sep 17, 2013 10:47 pm

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!

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 22064
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, The Netherlands
Contact:

Re: Database connection error (2): Could not connect to MySQ

Post by pe7er » Tue Sep 17, 2013 11:03 pm

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.'
Welcome to Joomla forum!

You have to check and maybe change your database credentials,
see http://docs.joomla.org/Unable_to_connec ... e_database
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.
You can use FTP (e.g. FileZilla) to access the files of your Joomla website.
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

UnderwaterN0w
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Sep 17, 2013 10:39 pm

Re: Database connection error (2): Could not connect to MySQ

Post by UnderwaterN0w » Tue Sep 17, 2013 11:21 pm

pe7er wrote:
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.'
Welcome to Joomla forum!

You have to check and maybe change your database credentials,
see http://docs.joomla.org/Unable_to_connec ... e_database
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.
You can use FTP (e.g. FileZilla) to access the files of your Joomla website.
Joomla's configuration.php should be in the root of your website (in a folder probably called www, public_html, htdocs)
Thanks for the quick reply, pe7er.

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?

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 22064
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, The Netherlands
Contact:

Re: Database connection error (2): Could not connect to MySQ

Post by pe7er » Wed Sep 18, 2013 12:20 am

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?
Yes, your Joomla user + password = for login into Joomla only.
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

UnderwaterN0w
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Sep 17, 2013 10:39 pm

Re: Database connection error (2): Could not connect to MySQ

Post by UnderwaterN0w » Wed Sep 18, 2013 12:40 am

pe7er wrote:
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?
Yes, your Joomla user + password = for login into Joomla only.
For FTP you'll have a different username + password.
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.

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. :)

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 22064
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, The Netherlands
Contact:

Re: Database connection error (2): Could not connect to MySQ

Post by pe7er » Wed Sep 18, 2013 10:59 am

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.
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:Is there a separate FTP username + password that I need to activate?
Depends on your hosting company.
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.
UnderwaterN0w wrote:As you can probably tell, this is the first time I've ever used a FTP so please be patient with me. :)
No worries! We have all been there :)
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

UnderwaterN0w
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Sep 17, 2013 10:39 pm

Re: Database connection error (2): Could not connect to MySQ

Post by UnderwaterN0w » Thu Sep 19, 2013 10:59 pm

pe7er wrote:
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.
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:Is there a separate FTP username + password that I need to activate?
Depends on your hosting company.
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.
UnderwaterN0w wrote:As you can probably tell, this is the first time I've ever used a FTP so please be patient with me. :)
No worries! We have all been there :)
Thanks a lot, I managed to find my FTP username and password and I found my configuration.php file.

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!

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 22064
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, The Netherlands
Contact:

Re: Database connection error (2): Could not connect to MySQ

Post by pe7er » Thu Sep 19, 2013 11:18 pm

UnderwaterN0w wrote:1. Instead of starting with 'var' (what does this stand for?), my database settings start with 'public' - is that correct?
Yes, in J2.5 it starts indeed with 'public'.
UnderwaterN0w wrote:2. For my $host it says '*database name*. db.*some numbers*.hostedresource.com' - is this OK?
This setting depends on your host, but I guess that it looks correct.
UnderwaterN0w wrote:3. For my $user it has my database account, not my Joomla admin one - is this OK?
Yes, because the configuration.php is for Joomla to access 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?
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:5. How do I find out what my $dbprefix should be?
with phpMyAdmin you can see all the database tables of your Joomla site, including their prefix..
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

UnderwaterN0w
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Sep 17, 2013 10:39 pm

Re: Database connection error (2): Could not connect to MySQ

Post by UnderwaterN0w » Fri Sep 20, 2013 1:26 am

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.
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:
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.

User avatar
leolam
Joomla! Master
Joomla! Master
Posts: 19481
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

Post by leolam » Fri Sep 20, 2013 5:07 am

UnderwaterN0w wrote:What should I do?
change with ftp the permissions from the configuration.php file to 644 and save again

Leo 8)
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

UnderwaterN0w
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Sep 17, 2013 10:39 pm

Re: Database connection error (2): Could not connect to MySQ

Post by UnderwaterN0w » Fri Sep 20, 2013 3:39 pm

leolam wrote:
UnderwaterN0w wrote:What should I do?
change with ftp the permissions from the configuration.php file to 644 and save again

Leo 8)
Thank you! I can now finally see my website's content again. :) I have no idea why the password wasn't set properly, I'm sure I didn't change it.

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?

User avatar
leolam
Joomla! Master
Joomla! Master
Posts: 19481
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

Post by leolam » Fri Sep 20, 2013 4:01 pm

UnderwaterN0w 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.
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 8)
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

UnderwaterN0w
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Sep 17, 2013 10:39 pm

Re: Database connection error (2): Could not connect to MySQ

Post by UnderwaterN0w » Fri Sep 20, 2013 5:16 pm

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 8)
Hi 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?

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 22064
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, The Netherlands
Contact:

Re: Database connection error (2): Could not connect to MySQ

Post by pe7er » Sat Sep 21, 2013 7:56 am

UnderwaterN0w wrote:Also, out of interest, why is running a database with the jos_ prefix considered a high security risk?
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.
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

User avatar
leolam
Joomla! Master
Joomla! Master
Posts: 19481
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

Post by leolam » Sat Sep 21, 2013 9:02 am

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.
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!)

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 8)
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

UnderwaterN0w
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Sep 17, 2013 10:39 pm

Re: Database connection error (2): Could not connect to MySQ

Post by UnderwaterN0w » Tue Sep 24, 2013 2:05 am

pe7er wrote:
UnderwaterN0w wrote:Also, out of interest, why is running a database with the jos_ prefix considered a high security risk?
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.
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....
I understand. So how do I go about changing my database to another prefix?

UnderwaterN0w
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Sep 17, 2013 10:39 pm

Re: Database connection error (2): Could not connect to MySQ

Post by UnderwaterN0w » Tue Sep 24, 2013 2:09 am

By the way, I finally managed to fix the problem! ;D

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

It's fair to say that my first impressions of the Joomla community have been very positive!

User avatar
leolam
Joomla! Master
Joomla! Master
Posts: 19481
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

Post by leolam » Tue Sep 24, 2013 4:31 am

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 8)
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

Kenster88
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Fri May 16, 2014 2:15 am
Location: New Hampshire, USA

Re: Database connection error (2): Could not connect to MySQ

Post by Kenster88 » Sun Aug 03, 2014 3:07 pm

Video tutorial I put together: :geek:
http://youtu.be/gLJlYQhpst0

Hope it helps!

Ken


Locked

Return to “Performance - Joomla! 2.5”