2

I'm trying to get MySQL running on my Mac. I used macports for the initial install but can't get past this mysql socket error. Note: macports appends the version number to commands if they look odd below.

Error:

Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'

I get this error when:

mysqladmin5 -u root password
and also
mysql5 -u root -p

My install and start process
Installed mysql with macports:

sudo port install mysql5 +server
sudo /opt/local/lib/mysql5/bin/mysql_install_db --user=mysql

Started like this:

sudo /opt/local/bin/mysqld_safe5

Also tried:

sudo /opt/local/share/mysql5/mysql/mysql.server start

How I've tried to solve this
I tried adding to the my.cnf file

[mysqld_safe] socket = /tmp/mysql.sock

Only problem is there wasn't a my.cnf file to begin with so I'm not sure if I created it in the right place.

I was also going to sim link the mysql.sock file to the /tmp dir but there's no mysql.sock file anywhere on the system.

So I created a mysql.sock file

touch /tmp/mysql.sock
But this didn't work either.

I'm thinking maybe I missed something in the install process since I can't find the my.cnf or mysql.sock file on the system.

Here's the guide I used:
http://2tbsp.com/content/install_and_configure_mysql_5_macports

3
  • Are you absolutely sure it isn't already running? Oct 30, 2009 at 23:04
  • Could you post what is in the config file? The file is my.cnf and it is found in /etc/.
    – user45687
    Jul 6, 2010 at 14:47
  • I confirmed this on my Macbook Air. I installed mysql55 with macports and I can start the server locally and log in. If I try to tunnel to a server, I cannot log in. I get the same error. I am sure the port is correctly forwarded because I can log in using Sequel Pro just fine. Apr 9, 2013 at 23:26

3 Answers 3

3

Find your mysql.sock then create a symlink from /tmp/mysql.sock to that path

locate mysql.sock
ln -s /path/to/real/mysql.sock /tmp/mysql.sock
1

I'd suggest getting the MySQL OSX package from http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg

These work just fine and include the startup scripts and a MySQL preferences pane.

0

The following was posted by Jonathan Bexiga on the MySQL forums & it worked for me. Basically don't use sudo when starting up.

I had also created the symlink as previously referenced, so that may also be required as part of the fix.

I found the fix. For anyone else who may run into this exact problem what you need to do is log in as root. Open up terminal. Type /usr/local/mysql/bin/mysql_safe. Hit ctrl+z. Then type /usr/local/mysql/bin/mysql. It worked for me.

1
  • Dude, that is a normal MySQL install, not from MacPorts. Different issue. Notice all Macports are in /opt/local/ Apr 9, 2013 at 23:28

You must log in to answer this question.