Saturday, November 1, 2014

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

Overview 

This is about
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'

Solution

I installed mysql 5.5.40 using a tarball on a non standard location

One the software installed and the instance created/started I wanted to secure it using mysql_secure_installation.

If you are not using the default socket /tmp/mysql.sock mysql_secure_installation won't work and you will get the following error
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'

In order to fix the issue, there is a simple solution :

1. create a soft link in /tmp for your socket
EX: ln -s /mysql/admin/mysql1/socket/mysql1.sock /tmp/mysql.sock

2. run your mysql_secure_installation

3. once completed remove the soft link
rm -f /tmp/mysql.sock

Problem fixed

No comments:

Post a Comment