Link to home
Start Free TrialLog in
Avatar of ducky801
ducky801Flag for United States of America

asked on

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

Asking on behalf of a friend:

I recently transferred my domain from one hosting co to Godaddy.com. All files have been transferred to my new hosting site. However, when going to the web page - www.treasuresforzoe.com - I'm getting the error - 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2).

I've read many forums and it appears to have something to do with permissions. I'm a beginner with MySQL and PHP at best so I'm unable to resolve. Can anyone please give me some basic, step-by-step instructions on how to resolve this, if it is something to do with cubecart? Much appreciation in advance!
Avatar of gunny051499
gunny051499
Flag of Italy image

Hi ducky801,

no idea about what cubecart or Godaddy.com is, but....

1) can you "see" /var/lib/mysql/mysql.sock ?
2) what are the rights there?
3) have you tried accessing mysql through TCP sockets instead of local unix sockets?

About the last question: you will need to find the place you are calling "mysql_connect". It should be enough to put the IP-address of your mysql server into the configuration file, where you configured your username + password. When using an IP address the mysql-client build into PHP won't try to use the unix socket.

Cheers

Gunny
Avatar of ducky801

ASKER


Thank you for the quick response! Cubecart is the shopping cart capability that I'm using on my website; it runs with PHP and MySQL. Godaddy is my hosting service.

I cannot see the /var/lib/mysql/mysql.sock anywhere so I can't answer your next two questions. Since I'm using godaddy as my hosting service, I'm doing everything thru their online interface so I'm unsure of how to find the IP address of the MySQL server.
There is a PHPMyAdmin tool that I can use to manage the content, as well as MySQL online interface.

Again, this is all very new to me so it's challenging to speak technically about it. I appreciate your help and patience.
Hi ducky801,

very well. If you can't see /var/lib/mysql/mysql.sock (I assume you have shell access) this means there definitely is no such thing as a local unix socket and you need to connect through an IP address.

Maybe you are able to find the file "includes/global.inc.php" in your cubecart folder. That's where the settings are if http://www.siteground.com/tutorials/cubecart/cubecart_manual_installation.htm is correct.

Cheers

Gunny
Gunny,

Yes, I have found and can access the code of the 'includes/global.inc.php' file on my hosting file manager. Here is the code for it. What in here should I change?

Thanks!

<?php
    
    $glob['dbdatabase'] = 'jmhuntle_ccrt1'          ;
    $glob['dbhost'    ] = 'localhost'        ;
    $glob['dbusername'] = 'jmhuntle_ccrt1'        ;
    $glob['dbpassword'] = 'omitted'        ;
    $glob['dbprefix'  ] = ''                   ;
    $glob['installed' ] = '1'                  ;
    $glob['rootDir'   ] = 'html/store'       ;
    $glob['rootRel'   ] = '/store/' ;
    $glob['storeURL'  ] = 'http://www.treasuresforzoe.com/store' ; 
?> 

Open in new window

Hi ducky801,

that's the one. The dbhost setting is what i was looking for.
But that setting is already set to localhost.

Is this system running a dedicated linux instance for you? Can you start/stop services on it? (inside your shell change to root user and execute "/etc/init.d/mysql start".

If you are not the admin of this system this won't work though. Please check what processes are running in case this should be a shared server (if cpanel is used that is quite probable). Issue "ps xa" to see all running processes and let me know.

Cheers

Günther
Thanks Gunny,
 
This is a shared linux server and I have no administrative access to diagnostic tools, nor can I restart services, etc. From the code I sent, should I change something in it? I welcome your suggestions.
ASKER CERTIFIED SOLUTION
Avatar of gunny051499
gunny051499
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This worked!!!  Thanks for the help!