How to define custom path to MySQL socket file?
Your error message says it's connecting to the wrong socket:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
You can either specify that in command line:
mysql -S /var/lib/mysql-socket/mysql.sock ...
Or in the my.cnf file under the client section (this can also be in users home directory ~/.my.cnf
):
[client]
socket=/var/lib/mysql-socket/mysql.sock