PDA

View Full Version : Error 2002: Cant Connect To Local MySQL Server Through Socket


Acid
11-07-2007, 09:16 PM
Well that's the error I'm getting when trying to connect to my MySQL database, more specifically:

Error 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
I know the PHP is fine because it's a straight copy and paste from a site I wrote before that's working fine (on the same host as well no less), anyway I did a bit of Googling and all the results that came up said that it's a configuration issue and can be resolved in several ways (mysql daemon, the my.cnf file etc etc) only problem is I'm on a shared hosting service so I don't have access to this. Does anyone know of any other potential cause to this problem other than configuration issues or is it just a call up the host deal?

CFMaBiSmAd
11-07-2007, 10:03 PM
Just because you are on the same host, does not mean the web site is on the same web server as before or that the mysql server you have access to is the same one as you previously were using.

Check in your control panel's database section and/or with your host for the proper mysql server hostname or ip address that you should be using with the current web site.

guelphdad
11-08-2007, 02:00 AM
Is the mysql server running? IIRC that error message means it isn't.

Acid
11-08-2007, 10:29 AM
Just because you are on the same host, does not mean the web site is on the same web server as before or that the mysql server you have access to is the same one as you previously were using.
I know, I was joking about that and was just to point out that I know it's not a PHP issue, both of the sites use a Linux shared hosting package, and the site that works correctly is the next account up from the one the site in question is using, the other site allows 10 sql databases which you create yourself through phpMyAdmin, this account only provides one database that's already created for you so I'm thinking that's probably the configuration issue there, bad setup on the part of the host perhaps?

Check in your control panel's database section and/or with your host for the proper mysql server hostname or ip address that you should be using with the current web site.
Had a look through that last night before posting on here, the CP for the site's onyl references to MySQL direct you to phpMyAdmin and all the confirmation emails, faqs for them etc mention nothing about using something other than localhost to connect (infact all their examples for connection use localhost)

Is the mysql server running? IIRC that error message means it isn't.
It must be running because the host provide phpMyAdmin as part of the control panel for the site and that works with the database fine hence why I was wondering if there could be any other causes to this problem aside from configuration but then I would've thought that would stop phpMyAdmin from working as well?

Acid
11-14-2007, 10:40 AM
It's working again now, turns out the host in their infinite wisdom had decided to change the default host name to something other than localhost and just hadn't told anyone about it, I forgot I was psychic.