mysql error error: ‘Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)’
If you have done a fresh mysql install from tarball, its possible you might encounter the following error when trying to use a client such as mysqladmin etc.. :
error: ‘Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)’
This might occur even if the mysql binary is running and the services seems to be listening on port 3306.
One common reason for this is that your my.cnf file doesnt have the correct location for your sock file.
Check it out, have a look in /etc/my.cnf and ensure that the sections under [mysqld] and [client] point to the correct location for your mysql.sock file – likely /var/lib/mysql/mysql.sock
You may find that the [client] section is missing, in which case just create it as below:
[client]
socket=/var/lib/mysql/mysql.sock
that hopefully will allow your client to now connect.