Page 1 of 1

[SOLVED] How to troubleshoot "Attempt to connect to database ... failed" error

Posted: Sun May 30, 2010 11:09 pm
by ESBertrand
Hi all.  I have two 1.6.3 CMSms installs that have been working great, both running on my website host under Windows with PHP 5.2.11 and MySQL 5.0.51a.

I have a third site to set up, but it's on a different host:  1and1, running under UNIX with PHP 4.4.9 and MySQL 5.0.67.  So I literally made a copy of one of my existing sites (both website files and DB backup), and changed config.php appropriately (DB connections and paths).  I've double- and triple-checked the settings but no matter what I try I'm getting this error, both via /index.php and /admin:

Code: Select all

Fatal error: Attempt to connect to database [dbname] on [dbusername]@[dbhost]
   failed in /homepages/13/d318687414/htdocs/lib/adodb.functions.php on line 69
where the values in brackets are the appropriate values.

My database is set up with an exact copy of the database from another CMSms site.  I know I can connect to the database since I tried a test PHP script which does a simple connect (retrieved via this link: http://www.wallpaperama.com/forums/simp ... t5702.html), and it works.

This is a pretty vanilla 1and1 setup, nothing special enabled that I know of.  I'm a proficient C# programmer who can get by in PHP, but I'm not sure what I can do to troubleshoot why CMSms cannot connect.  Help!

Erik

Re: How to really troubleshoot "Attempt to connect to database ... failed" error

Posted: Sun May 30, 2010 11:53 pm
by Nullig
You could try installing a clean site from scratch, to see if it works. Then you know it's something in the copying.

Nullig

Re: How to really troubleshoot "Attempt to connect to database ... failed" error

Posted: Mon May 31, 2010 5:36 am
by GBR
Nullig wrote: You could try installing a clean site from scratch, to see if it works. Then you know it's something in the copying.

Nullig
Oops, where did that reply go?

Another good test is to connect from the command line on your web server:

Code: Select all

mysql -u <database user name> -p <database password> -h <database host name> <database name>
I normally find the problem is the GRANT. "GRANT ALL TO .* TO fred IDENTIFIED BY '******';"  is only for localhost. You need "fred@'192.168.0.*'", for example, to grant access from the 192.168.0/24 subnet or "fred@'192.168.0.109'". Multiple GRANTS if there are multiple IPs. Not to mention the firewall which, if there is one, must allow the MySQL port through.

Re: How to really troubleshoot "Attempt to connect to database ... failed" error

Posted: Mon May 31, 2010 1:04 pm
by ESBertrand
Thanks Nullig and GBR.  I don't really have a command line since this is managed hosting through 1and1, but I am trying to install the latest version; problem is, the server I'm on appears to have PHP 4.4.9.  Geez....

In posting, I am asking if I could do anything within CMS Made Simple to troubleshoot the connection issue.  Namely, is there a way to report what specific error was returned by the login?  Again, I know I can connect through a simple PHP script just fine; it's CMS Made Simple that cannot seem to connect.  I know it's using ADOLite and mysqli, so perhaps there's a setting there I need to tweak?

I guess I was hoping for some PHP or MySQL log I could check for more detailed error information.

Erik

Re: How to really troubleshoot "Attempt to connect to database ... failed" error

Posted: Mon May 31, 2010 4:51 pm
by Nullig
You can turn on debug in the config.php file:

Code: Select all

# CMSMS Debug Mode?  Turn it on to get a better error when you
# see {nocache} errors, or to allow seeing php notices, warnings, and errors in the html output.
# This setting will also disable browser css caching.
$config['debug'] = true;
This will give you more mysql error info.

Nullig

[SOLVED] How to troubleshoot "Attempt to connect to database ... failed" error

Posted: Wed Jun 02, 2010 2:53 am
by ESBertrand
Thanks for the logging tip, Nullig.

I've gotten by the problem.  I installed a fresh copy of the latest (1.7.1) and it was able to connect, and in the process I switched up to PHP 5.2.13.  I then upgraded the version I had tried before (1.6.3) to 1.7.1, ran the upgrade process, and all was fine.  Kind of strange, but it's running great now.  Faith restored...  :)

Again, many thanks for the replies!

Erik