Free web analytics, website statistics Statistics

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) PDF Print E-mail
Written by Administrator   
Wednesday, 13 August 2008

For some reason the other day all of the websites on my server just loaded a blank page. After restarting the server php was up and running again but none of my joomla sites could work because MySQL was not running. After many hours of searching the web and trying many different things I finally found a solution that worked for me.

Its a good idea to view the MySQL logs

# cd /var/log
# vi mysqld.log

While trying to start MySQL I received the error below:

# mysql start
# ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

So I tried to start mysqld

# cd /etc/rc.d/init.d/
# ./mysqld start
# open: Permission denied

Next check out to make sure the socket is pointed in the right direction. Press :q to exit without saving. Or :wq to save and exit

# vi /etc/my.cnf

[mysqld]
set-variable=local-infile=0
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

skip-bdb

set-variable = innodb_thread_concurrency=2
[mysql.server]
user=mysql
basedir=/var/lib

[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
skip-bdb

set-variable = innodb_thread_concurrency=2


If the socket is pointed to the right location and it mysql.sock does not exsist it has to be recreated. 

# mysqld_safe --user=mysql &

That fixed it for me. Turns out someone was trying to send a sql injection though the url on a different site on this server which caused a mysql overload so Godaddy pulled the socket to kill mysql. A call to inform me would of been nice but my site was not hacked so I am happy.

 

 

Last Updated ( Wednesday, 13 August 2008 )
 

Login Form






Lost Password?