0

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

while resetting the root password on mysql in root in Linux I am Facing Following Error?

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

how to Fix?

MySQL Add a comment
muhammad ahmad
asked May 09 2019

Answer

0

First You need to Find a path of socket inside the /etc/my.cnf file.

For ex: /var/lib/mysql/mysql.sock

Just remove the file if it already exist /var/lib/mysql/mysql.sock

Now newly Create a file named as mysql.sock in /var/lib/mysql/

set the ownership and permission as shown below

chown mysql.root mysql.sock
chmod 775 mysql.sock

Restart the service use the command as follow service mysqld start
Then you can set or reset the password of root user in mysql

mysql_secure_installation

Just press enter while asking the default root password of mysql
Then you can proceed with set the new password and user privileges to accessing the mysql

Add a comment
linuxhelp
asked May 09 2019
Post your Answer