I am trying to connect with mysql 5.6 in Linux with:
[C003@C-003 mysql]$ mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
I am getting above error. I found lot of hints but not one working for me and I cant take so much risks for Live server.
some commands output as follow:
[C003@C-003 mysql]$ service mysql status
ERROR! MySQL is running but PID file could not be found
[C003@C-003 mysql]$ ps -ef|grep mysql
root 1419 1 0 Apr28 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/SI-CloudDB-003.pid
mysql 1731 1419 6 Apr28 ? 20:58:36 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/SI-CloudDB-003.err --pid-file=/var/lib/mysql/SI-CloudDB-003.pid --socket=/var/lib/mysql/mysql.sock --port=3310
501 30843 28738 0 11:41 pts/2 00:00:00 grep mysql
Issue fixed. I create file at /var/lib/mysql/mysql.sock and set ownership to MySQL user and group. When try to shutdown the service I got error "Can't connect to local MySQL server through socket '/var/mysql/mysql.sock'". I kill the mysql background process through kill -9 process_id and then start the mysql service. Now its working fine.