Page 1 of 1

[Solved] Can't connect to local MySQL server ...

Posted: Thu Aug 21, 2008 11:09 am
by Evil Phil
Hello,

So the background is I've moved from my dev box to a hosting server. Details on the hosting server are:
CMS Made Simple Version 1.2.3.
PHP Version 4.4.7
Apache/1.3.37 (Unix)
MySql Version 4.1.15

Dev box details are in my sig if anybody should want them.


I've followed the moving server steps in the wiki to a T. Now when I visit the site I get the following error:
Database Connection Failed
Error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) (2002)
Function Performed: CONNECT
Host/DB: localhost/ dbname
Database Type: mysql

I've copied up the install folder to see if that would work and it does but fails at the db step, returning error message: Could not connect to the database. Verify that username and password are correct, and that the user has access to the given database.

PHP is working as I've included a test.php file to return phpinfo() at the root and it works fine. I'm coming from Windows so the *nix stuff is all new to me. Anybody got any suggestions as to how I should troubleshoot this problem?

thanks in advance.

Re: Error: Can't connect to local MySQL server ...

Posted: Thu Aug 21, 2008 11:13 am
by Nick Smart
Have you correctly updated all the database name, username and password details and all the URLs in your config.php?

Nick

Re: Error: Can't connect to local MySQL server ...

Posted: Thu Aug 21, 2008 11:15 am
by Evil Phil
Yeah, sorry I should have said that. They are all correct - I'm using 'localhost' for $config['db_hostname'], there is a MySql URL coming from the host too but if I use that then I just get a blank page with no error, not my homepage.

Re: Error: Can't connect to local MySQL server ...

Posted: Thu Aug 21, 2008 11:47 am
by Nick Smart
Have you specified the database name and username correctly, e.g. if your hosting account is "evil" and you create a database called "cms" the database name is usually "evil_cms" and the username is likley to be "evil_myuser".

Also, try creating a simple php program to check you can connect to the db, nothing to do with cmcms, e.g.:

Code: Select all

<?php
$connect = mysql_connect( "localhost", "evil_myuser", "very-secret" );
@mysql_select_db( "evil_cms", $connect ) or die( "ERROR: Unable to connect to the database" );
echo "<p>It worked!</p>";
?>
(all code untested).

Nick

Re: Error: Can't connect to local MySQL server ...

Posted: Thu Aug 21, 2008 12:06 pm
by Evil Phil
Okay then progress has been made. I've ran you're little php page and changed from localhost to the address of the mysql box and that worked. Problem is now I'm getting an empty document served when I go to the homepage or the admin page.

But I suppose that's a different problem, I'll flag this one as solved. However if you've any ideas as to why its blank or how to trouble shoot that I'd be most grateful :D

Thanks Nick, you should get a karma+1 for that.