Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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%5Fand%5Fconfigure%5Fmysql%5F5%5Fmacports

share|improve this question
    
Are you absolutely sure it isn't already running? –  Paul Tomblin Oct 30 '09 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 '10 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. –  macmadness86 Apr 9 '13 at 23:26
add comment

3 Answers

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
share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
    
Dude, that is a normal MySQL install, not from MacPorts. Different issue. Notice all Macports are in /opt/local/ –  macmadness86 Apr 9 '13 at 23:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.