I’m working on a Mac with OS X 10.5.7 and a fresh XAMPP 1.0.1 install. XAMPP gives your OS X a complete Apache, MySQL and Perl/PHP installation to work with. With it, you can develop on your Mac with a complete web server. (Sure, Mac comes with most of this stuff built in, but XAMPP is really nice and allows you to have your Mac web services turned off for security.)
XAMPP also comes with phpMyAdmin for managing your MySQL server through a web page. I find phpMyAdmin to be awesome for most of what I do with a database. Sometimes I need to revert to command-line for large datafiles and stuff, but I’d say 99.9% of the time I can use phpMyAdmin for what I’m doing. I ran into a problem with phpMyAdmin trying to view a database table that was imported from an Excel export. For some reason, the phpMyAdmin page is just plain white – making me think there was some web/parsing/display problem involved. I needed a different way to view the DB. For this kind of thing I hate the command line. (The line wrapping…blech!)
MySQL makes a set of GUI tools, too. But when I installed them, and tried to connect to my DB, I kept getting a 2002 connection error code; something like:
ERROR 2002: Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
The normal solution to something like this is you have the wrong username/password or you cannot connect to the server. But that is not always the case.
The real problem is that the GUI tool could not use mysql.sock – which didn’t even exist. XAMPP’s installation of MySQL uses a different socket file under /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock. This is configured in XAMPP by the /Applications/XAMPP/etc/my.cnf file.
NOTE: edited with a
simpler permanent method First thing I did was make a soft link to the my.cnf file in /etc. This makes the my.cnf accessible from a more “normal” location on a Unix system (which Mac OS X is a flavor of) by making a new file that actually points to the XAMPP one in it’s original location.
ln -s /Applications/XAMPP/xamppfiles/etc/my.cnf /etc/my.cnf
Then I made a soft link to the XAMPP mysql.sock file.
ln -s /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock /tmp/mysql.sock
If you click the “More Options” twisty on the connection dialog, you will see a cryptically labeled field called “Connect using socket:”. Put the path to your mysql.sock file in that field. Mine was located at
in a standard XAMPP installation. (MAMP will be slightly different).
Here is a screenshot:
After that I was able to connect with the MySQL Adminstrator GUI tool and Query tool.
This may save you some trouble if you’re trying to do the same thing.
4 thoughts on “How do you get MySQL Administrator GUI to work with XAMPP on Mac OS X?”
Hi Eric, thx for the fast update.
Dennis, I updated the description with a better solution. Thanks for pointing this out!
Very good workaround! But this is not a permanent solution. Every time I restart my Mac the soft link is gone! Any idea?
Thanks! Cheers Dennis
Another thing I’ve had to resort to on my Mac from time to time is specifying the host as 127.0.0.1 instead of localhost when using command line tools. I remember reading somewhere (?) that this is a workaround to an issue w/ IPv6 on the Mac and MySQL. I have no idea if I really need to keep doing this, or if I’m doing it just out of superstition at this point.