Friday, 1 September 2017

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

Today i have changed the mysql datadir directory default to new one

This is the steps which i followed to change


[root@testing-server~]# service mysqld stop
[root@testing-server~]# mkdir /wesites/mysql
[root@testing-server~]# cp -prvf /var/lib/mysql /websites/mysql/

[root@testing-server~]# vim /etc/my.cn
f

        datadir=/websites/mysql       
        socket=/websites/mysql/mysql.sock


[root@testing-server~]# service mysql start

After these steps mysql started but i can't able to login locally. i got the error instead of successful login





   
Solution :

I have added the following things on /etc/my.cnf file

[root@testing-server~]#  vim /etc/my.cnf


    [client]
    socket=/websites/mysql/mysql.sock



[root@testing-server~]# service mysql restart


Now i can able to login locally






No comments:

Post a Comment