I am trying to access MySql on my Ubuntu 10.04 LTS (lucid) system. I am aware that there are a lot of results out there for this error but none seem to be helping me. I am a novice on Linux so any help might need to be spelt out.

When running

mysql -u root -p

at the command prompt, I receive the error

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)

The sock file definitely exists; running

sudo ls -la /var/lib/mysql

includes the line

-rwxrwxr-- 1 mysql mysql 0 2011-11-03 19.05 mysql.sock

and running ls on the parent directory looks like this

sudo ls -la /var/lib
drwxr-xr-- 5 mysql mysql 4096 2011-11-03 18.14 mysql

I think MySql is running;

sudo service mysql start

results in

mysql start/running

And the my.cnf file (located at /etc/mysql/) includes the line

socket = /var/lib/mysql/mysql.sock

under the [mysqld] section.

Any pointers would be greatly appreciated. This site is live and since it is hosting a WordPress installation, not being able to access MySql completely breaks the site!

EDIT

Output from comment;

ps -ef | grep mysql
mysql     1869     1  0 20:15 ?        00:00:00 /usr/sbin/mysqld
pete      1953  1713  0 20:36 pts/0    00:00:00 grep --color=auto mysql
link|improve this question
1  
what does the output of ps -ef | grep mysql show ? – Iain Nov 3 '11 at 20:13
See the edit for the output – smix96 Nov 3 '11 at 22:43
754 is a very odd mode to see for the /var/lib/mysql directory. – Adrian Jan 27 at 14:05
feedback

3 Answers

mysql.sock is NOT a socket file, it is a standard file with 0 byte size.

I'd (1) terminate mysql, (2) delete the mysql.sock file, and then (3)restart mysql which will properly make the socket file. You should see a socket file looking like the following when doing an ls -l mysql.sock.

 srwxrwxrwx 1 mysql mysql            0 2011-10-06 15:25 mysql.sock
link|improve this answer
Ok, I've deleted it using sudo rm mysql.sock. Now doing ls -l mysql.sock does result in what you've posted however I still get exactly the same error as before. – smix96 Nov 3 '11 at 20:24
Also, it looks like you are getting some type of file permission problem indicated by error 13. So I'd start investigating that as well. – mdpc Nov 3 '11 at 20:35
I'm really not sure how I would go about investigating that. Any starting points? – smix96 Nov 3 '11 at 20:40
I have run CHOWN -R mysql:mysql /var/lib/mysql I don't know if this should allow mysql all it requires? – smix96 Nov 3 '11 at 21:15
feedback

mysqld should have its socket file somewhere under /var/run. On my debian system it's /var/run/mysqld/mysqld.sock.

/var/lib/mysql is the directory for the actual database, not runtime information.

link|improve this answer
feedback

Do the following: chmod 755 /var/lib/mysql

link|improve this answer
Changing the rights so everyone on the server can just shut down and restart your mysql process is not a good way to solve this problem. This is a security threat even. – Lucas Kauffman Jan 28 at 6:31
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.