Installing MySQL on Snow Leopard

I had all sorts of trouble installing MySQL on Snow Leopard. I never had any trouble installing mysql on Ubuntu.

Installing it normally on Snow Leopard would give me a success screen saying it had been installed but it seemed to have completely failed to install.

I then installed and used macports and that was the start of the solution. If I was trying to install MySQL on Lion or Mountain Lion I think I would try macports first.

You need to get xcode (to use macports) if you didn’t have it already you are going to have some challenges because I couldn’t find it in the Apple developer center (they removed it since I guess you shouldn’t be still using Snow Leopard in their opinion). Luckily I already had xcode installed.

To install mysql using macports

[bash]sudo port install mysql5[/bash]

Then you will avoid a bunch of frustrating errors (though you may enjoy that process) if you realize you need the server msql also.

[bash]sudo port install mysql5-server[/bash]

Pay attention to the messaging when you do that and you will see, suggestion to

[bash]sudo -u _mysql mysql_install_db5[/bash]

See the instructions that show for lots more on how to deal with that failing, as it did for me. Or celebrate if it worked.

Go ahead and add mysql to the default path open your .bash_profile or .profile

[bash]vim ~/.profile[/bash]

Then I tried sudo /opt/local/share/mysql5/mysql/mysql.server start but that failed. At which point I found that macports has its own version

[bash]sudo port load mysql5[/bash]

Which worked.

To login to MySQL you can use (root is created with no password on install).

[bash]mysql5 -uroot -p[/bash]

Go ahead and change the root password as the first thing you do.

Related: Getting Ruby on Rails & mysql setup on a Mac OSX Leopard clean installMacPorts doesn’t install org.macports.mysql5.plist with mysql5 +serverMySQL Performance Tuning TipsMySQL cli Syntax