I am having troubles logging into mysql from the command line. I keep on getting the following error: ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

Article ID: 171 
Last Review: Oct,6 2008
Author: APPLIES TO:
  • Plesk for Linux/Unix

Resolution

First of all make sure that mysql is running with:

<>
ps ax | grep mysql | grep -v grep
4081 pts/8 S 0:00 /bin/sh /usr/bin/safe_mysqld --defaults-file=/etc/my.cnf --pid-file=/var/run/mysqld/mysqld.pid
4110 pts/8 S 0:00 /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking



If it is so, try to create a link from the /tmp/mysql.sock:

ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock


Subscription for this article changesSubscription for this article changes

Please provide feedback on this article

Did this article help you solve your issue?
Yes
No
Partially
I do not know yet
 
Strongly Agree   Strongly Disagree
  9 8 7 6 5 4 3 2 1
The article is easy to understand
The article is accurate
Additional Comments:
*Please provide us with your email address in case we need to contact you.
* - required fields