cancel
Showing results for 
Search instead for 
Did you mean: 

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

colinwbell
Newbie
Posts: 3
Registered: ‎03-12-2014

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

Just trying to get our old PHP/MySQL application working on the new CGI hosting platform.
PHP OK.
MySQL database logged in OK via hosting.plus.net Control Panel / MySQL Manager
Database login credentials correct in PHP database connect code, but getting runtime error:
#Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'#
Checked code for localhost references, none.
URL: http://ccgi.tynemills.plus.com/cars/index.php
Any thoughts?
With thanks, Colin.
4 REPLIES 4
bobpullen
Community Gaffer
Community Gaffer
Posts: 16,869
Thanks: 4,950
Fixes: 315
Registered: ‎04-04-2007

Re: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

Hi Colin,
Your SQL login credentials are wrong.
Checking one of your PHP files I can see references to 'humbug' and a pre-migration username/password and database name.
All 'humbug' instances should be replaced with what's in the 'DB Host' column of the MySQL Manager in the Control Panel. The old database table name (username_pn) needs replacing with what's in the 'Available Databases' column.

Bob Pullen
Plusnet Product Team
If I've been helpful then please give thanks ⤵

colinwbell
Newbie
Posts: 3
Registered: ‎03-12-2014

Re: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

Thanks for that Bob.
I've amended my db connect code as follows, but I'm still getting the error:
<? $res_conn = mysql_connect ("sql5c51a.megasqlservers.eu","tynemills_pn_ccgi_tynemills_plus_com","1a4af0f019fc7c7c");
$res_sel = mysql_select_db ("tynemills_pn");
    $datab='tynemills_pn';
    $dbusr = 'ccgitynemi966475';
    $dbpass = '6****1v';
    $dbhost = 'sql5c51a.megasqlservers.eu';
    ?>
Can you see where this is going wrong.
There was only the one reference to 'humbug' (now amended).
Thanks,  Colin.
bobpullen
Community Gaffer
Community Gaffer
Posts: 16,869
Thanks: 4,950
Fixes: 315
Registered: ‎04-04-2007

Re: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

Still various references to the old database name (tynemills_pn), you've the database name instead of the username in the mysql_connect statement and the same statement is using the wrong password.
I've backed up the relevant file with an appropriate file name and created a new one with the correct settings.
You should find it works now?

Bob Pullen
Plusnet Product Team
If I've been helpful then please give thanks ⤵

colinwbell
Newbie
Posts: 3
Registered: ‎03-12-2014

Re: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

Thanks Bob,
All working.  10 out of 10 for service and rapid response.
Colin