Question

I am using MySQL 5.6.26 Community Server on a Mac OSX 10.10.4.

The server is running, according to the preference pane utility. Also I can connect to the server using the command line tool with the common login:

./mysql -h localhost -u root -p

However, using the same credentials in MySQL Workbench gives me this error:

Can't connect to MySQL server on '127.0.0.1' (61)

I tested replacing localhost with 127.0.0.1 in the command line login wich gives the same error:

./mysql -h 127.0.0.1 -u root -p
Enter password: 
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (61)

I think there is an issue here with resolving localhost to 127.0.0.1, but I need help with further investigation.

Was it helpful?

Solution

When you specify localhost as the host to connect to, the mysql commandline client tries to connect using a local socket. To enforce a tcp connection you have to either set the host to 127.0.0.1 or use the --protocol=tcp parameter.

Your server is not configured to accept network connections so you have to switch to change your connection method to Socket/Pipe Path and set the path to the socket, something like /var/run/mysqld/mysqld.sock. You can check yours in the config or by running select @@socket; in the commandline connection. \s used as command in the CLI will tell you that too and some more info about your server.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top