0

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

thanks

  • 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. – John Gardeniers Feb 18 '10 at 22:02
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 127.0.0.1
0

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:

[mysqld]
socket=/var/run/mysqld/mysqld.sock

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.