Reputation: 173
I have just installed xampp
on Mac
.
I was trying to import an existing .sql
file to MySQL DB
on phpMyAdmin
.
It was a success.
But I cannot connect MySQL
using mysql browser like Sequel Pro
.
I think this is because of ERROR (2002)
This is the result when I type mysql
on the terminal.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock' (2 "No such file or directory")
Please help me how to fix this issue.
Upvotes: 1
Views: 13223
Reputation: 1564
Have you checked it out here. It means either the MySQL server is not installed/running, or the file mysql.sock doesn’t exist in /var/lib/mysql/.
There are a couple of solutions for this error.
service mysqld start
Then try to connect again.
If you connect to localhost, it will use the socket connector, but if you connect to 127.0.0.1 the TCP/IP connector will be used. So when the socket connector is not working, try connecting to 127.0.0.1 instead.
Find the file my.cnf (usually in /etc/) to edit and add these following line:
[mysqld]
socket=/var/lib/mysql/mysql.sock
[client]
socket=/var/lib/mysql/mysql.sock
Restart mysql and connect again.
In some cases, you mysql.sock might be located in another folder. You have to find and symlink it. You might find it in /tmp/mysql.sock or /data/mysql_datadir/mysql.sock
For example, your file is located as in /tmp/mysql.sock
Then symlink it:
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
Restart mysql and connect again.
Upvotes: 3