-1

Im a macbook user. I try to access mySQL through the terminal, but after entering the password, I receive an error message. Like this

Pasindu@Pasidus-Air ~ % mysql -h localhost -u root -p 
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

How to fix that problem.

Luuk
  • 12,245
  • 5
  • 22
  • 33

1 Answers1

0

When you're using unix domain sockets you cannot use -h flag. Use the following if socket path is default:

mysql -u root -p

If path is not default just pass -S flag.

mysql -u root -p -S /var/run/mysqld/mysql.sock
Alijvhr
  • 1,695
  • 1
  • 3
  • 22