views:

474

answers:

5

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

A: 

Mac moved where mysql.sock lives. I think one part want sit to be in /var/mysql, and something else wants it to be in /tmp. So, I made a symlink...

Brian Postow
yeah, i'd love to just symlink. unfortunately there's no mysql.sock anywhere to symlink.
bandhunt
A: 

Is mysqld even running (ps ax)? If it's not running, figure out why it's not running with the logs. I'm not familiar with the macports install of it, so I can't tell you.

As an aside, for development on my Mac I just grab the official mysql packages, which comes with a system prefs pane to start mysql for you. I've found fink/macports more trouble than they're worth, in general.

Jim Zajkowski
A: 

mysql.sock is created on the fly by the server process and removed once it exits. Creating it beforehand or symlinking won't work.

You'll need to figure out where to properly configure it. Apparently, this is done in /opt/local/etc/mysql5/my.cnf

jackrabbit
A: 

I spent a lot of time trying to get mysql running. Here, I think is part of the answer to your problem. Do a sudo port install mysql5-server. I just did that today and it fixed a lot of the problems I had when I just did sudo port install mysql5. Most of the hints on the interwebs are about mysql5-server not mysql5; the guide you used worked with me once I installed mysql5-server. Don't forget to delete the folders/files created from your previous install and do a sudo port uninstall mysql5. This question was asked about two months ago; hopefully this will put you back on track.

Avry
A: 

I posted my solution here: http://djcode.posterous.com/installing-mysql-on-mac-os-x-snow-leopard

Thanks for the help!

bandhunt
link is broken :(
evanmcd
fixed. sorry i moved my blog.
bandhunt