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.
1 Answer 1
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.
-
That solved it. The path for me is /tmp/mysql.sock. Looks like something temporary. Is this something to be concerned about?fr3d-5– fr3d-52015年09月25日 12:14:59 +00:00Commented 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.jkavalik– jkavalik2015年09月25日 12:19:25 +00:00Commented Sep 25, 2015 at 12:19
-
More info at dev.mysql.com/doc/refman/5.5/en/problems-with-mysql-sock.htmljkavalik– jkavalik2015年09月25日 12:20:25 +00:00Commented Sep 25, 2015 at 12:20
-
1localhost 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.Mike Lischke– Mike Lischke2015年09月26日 09:42:15 +00:00Commented Sep 26, 2015 at 9:42
-
@MikeLischke thanks for the clarification, I rewrote that part a bit.jkavalik– jkavalik2015年09月26日 11:39:11 +00:00Commented Sep 26, 2015 at 11:39
Explore related questions
See similar questions with these tags.