I am trying to install mysql 5.1.42 and after running below line

sudo /usr/local/mysql/bin/mysqladmin -u root -p password

I get this error:

/usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!

I have created mysqld.sock and gave permission to it too. but still get the same error.

can anyone help


  • Is mysqld actually running? You could also give us some clues, such as which OS you're using. BTW, there must be no whitespace between the "-p" and the password. Feb 18, 2010 at 22:02

2 Answers 2


Are you sure that mysql is really running? Do a

ps aux | grep mysql

to check this. Also it is often easier to connect via TCP/IP than via sockets:

mysql -u root -p -h

It is quite likely that your client and server have different ideas to where the socket lives.

If you have a /proc file system, finding where the server has put the socket is quite easy. The output from:

ps -elf | grep mysqld

should include the process id of one of the mysqld server threads (any will do). Then look in /procto see where the socket has been written:

sudo ls -l /proc/NNN/fd

where NNN is the process id from the "ps" call.

Once you know where the socket is, pass its location in the connect string:

sudo /usr/local/mysql/bin/mysqladmin -u root -S /path/to/mysqld.sock -ppassword

The socket location is normally specified in the mysql.cnf file (/etc/mysql/mysql.cnf or /etc/mysql.cnf or whatever), in the section headed "[mysqld]". If there is no socket entry in there, then the server will use the compiled in default which is /tmp/mysql.sock. You can always stop (or kill) the server, and add an explicit socket entry into the config file like:


It is worth adding the same to the [client] section so all the client tools have the same idea.

You must log in to answer this question.