2

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.

asked Sep 25, 2015 at 11:51

1 Answer 1

2

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.

answered Sep 25, 2015 at 12:08
5
  • That solved it. The path for me is /tmp/mysql.sock. Looks like something temporary. Is this something to be concerned about? Commented Sep 25, 2015 at 12:14
  • Thats the default. It can be configured, but the socket file exists when the service is started, so will be recreated after reboot. Commented Sep 25, 2015 at 12:19
  • More info at dev.mysql.com/doc/refman/5.5/en/problems-with-mysql-sock.html Commented Sep 25, 2015 at 12:20
  • 1
    localhost does not mean connection via socket. It's a synonym for the loopback address (127.0.0.1 or ::1, depending on the availability of IPv6 and the OS). However, the CLI automatically tries the socket too, which Workbench does not. Hence it fails if you try a TCP/IP connection if that method is not enabled. In MySQL Workbench there is an own connection method for sockets. Commented Sep 26, 2015 at 9:42
  • @MikeLischke thanks for the clarification, I rewrote that part a bit. Commented Sep 26, 2015 at 11:39

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.