Mysql – Can’t start MySQL on Mac OS X getting thesql.sock connection error

mac-osxMySQL

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

Best Answer

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