i try to connect to mysql server but it gives me socket issue i have edited my.cnf from /var/lib/mysql/mysql.sock to /home/mysql/mysql.sock
Nb: the issue exist before moving mysql db file to the new directory.
[root@dc ~]# /usr/bin/mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@dc ~]# ps aux | grep mysqld
root 8472 0.0 0.0 108216 1596 pts/2 S 10:18 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/home/mysql --socket=/home/mysql/mysql.sock --pid- file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
mysql 8691 0.1 0.0 543468 47860 pts/2 Sl 10:18 0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/home/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/home/mysql/mysql.sock
root 8825 0.0 0.0 103356 852 pts/2 S+ 10:20 0:00 grep mysqld
Mysqld directive under my.cnf:
[mysqld]
datadir=/home/mysql
socket=/home/mysql/mysql.sock
Best Answer
Try to add the socket to the my.cnf in the client directive.