[ubuntu-za] Can't connect to local MySQL server

Neil Muller neil at dip.sun.ac.za
Wed Jan 28 11:50:39 GMT 2009

On Wed, Jan 28, 2009 at 01:06:42PM +0200, Alf Stockton wrote:
> > Tried specifying "localhost" in the connection?
> > 
> > mysql -h localhost -u root -p
> >
> That gives me:-
> root at general:~# mysql -h localhost -u root -p
> Enter password:
> ERROR 2002 (HY000): Can't connect to local MySQL server through socket 
> '/var/lib/mysql/mysql.sock' (111)

This is an optimisation mysql does - connections to 'localhost' will be
redirected over the socket. It's not that promimently discussed in the
mysql docs, so it tends to cause a fiar number of 'Huh, what?' moments.

On Wed, Jan 28, 2009 at 12:22:02AM +0200, Alf Stockton wrote:
> root at general:~# ls -al /tmp/mysql.sock
> lrwxrwxrwx 1 root root 25 2009-01-28 10:18 /tmp/mysql.sock -> 
> /var/lib/mysql/mysql.sock
> root at general:~# ls -al /var/lib/mysql/mysql.sock
> -rw-r--r-- 1 root root 0 2009-01-28 11:40 /var/lib/mysql/mysql.sock

Um - that's not a socket (lack of a leading 's' in the ls output is a
giveaway here), so that's a problem (and the permissions look wrong to
me anyway - it should usually be writeable and readbale by everyone, not
just root). Somehow it's been created incorrectly. Removing this, and
restarting the mysql server should fix the problem.

Neil Muller  email: neil at dip.sun.ac.za 

Division Applied Mathematics, Department of Mathematical Sciences
University of Stellenbosch

More information about the ubuntu-za mailing list