Bug #37113 Unable to connect using socket when host = localhost
Submitted: 31 May 2008 0:39 Modified: 26 May 2009 13:09
Reporter: Ryan Lowe Email Updates:
Status: Unsupported Impact on me:
None 
Category:MySQL Query Browser Severity:S3 (Non-critical)
Version:1.2.12 OS:MacOS (10.5.2)
Assigned to: CPU Architecture:Any
Tags: Connect with socket, query browser

[31 May 2008 0:39] Ryan Lowe
Description:
When specifying connection parameters for MySQL Query Browser, if the Server Hostname is set to "localhost" and a socket is specified, the specified socket is not respected (an error is thrown with the following message: Could not connect to MySQL instance at localhost.  Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' ...).  The specified socket is /tmp/mysql.5.0.45.sock

However, it connects without a problem when 127.0.0.1 is specified.  

The contents of my /etc/hosts
bash-3.2# cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost	satan.local
255.255.255.255	broadcasthost
::1             localhost

The result of a ping
bash-3.2# ping localhost
PING localhost (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.063 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.059 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.061 ms
...

How to repeat:
0) Make sure that MySQL is not using /tmp/mysql.sock
1) Open MySQL Query Browser
2) Enter "localhost" into the Server Hostname field
3) Enter correct username/password information
4) Fill in the Connect Using Socket field with a valid socket
5) Click "Connect"
[31 May 2008 14:23] Sveta Smirnova
Thank you for the report.

Verified as described.
[10 Nov 2008 10:40] Lukas Treyer
Doing

sudo mkdir /var/mysql/
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

solved the problem for me.
[14 Jan 2009 23:34] Tami Russell
I'm so frustrated. I have followed all directions to the T for getting MySQL on Mac OS X 10.5.5 ... I cannot get The Server Instance to Start that I installed in System Preferences. It asks for a password, then nothing... I also cannot get it to connect throught the Admin, I get Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (code 2002) .. I'm a newbie .. please help!
Tami JO
[26 May 2009 13:09] Susanne Ebrecht
Many thanks for writing a bug report. We are on the way to implement full functionality of MySQL Query Browser into MySQL Workbench. Unfortunately you are using an unsupported platform. More informations about supported platforms you will find here:

http://www.mysql.com/support/supportedplatforms/tools.html

More informations about MySQL Workbench you will find here:

http://dev.mysql.com/workbench/
[7 Jun 2009 20:34] David Sadowski
ln -s didn't work for me for MAMP and MySQL WB for Mac :( it's useless if you cannot develop locally. The custom socket option field has been forgotten... what a shame.