I have a dark and painful history of installing MySQL the wrong way, which has forced many late nights and ungodly amounts of frustration. It should be super easy, and sometimes it is, but sometimes it is not. And it can suck.
This post is as much a documentation of what I did so I can re-read it the next time I screw up something as it is a tutorial for you. Let’s begin.
Don’t use MacPorts, use the .dmg from the MySQL website
MacPorts will give you MySQL 5.1.48 or something like it when you install the mysql5
port. The mysql55
port doesn’t upgrade your mysql5
port, it runs side by side and can be super confusing if you want to run terminal commands or change permissions on directories your forgot about when you installed mysql5
. mysql5-devel
doesn’t build on Mountain Lion yet. Awesome.
The .dmg
file will give you everything you need: installs beautifully in /usr/local/mysql
, provides a startup item installer that will fire up the mysqld_safe
launch daemon when you turn your computer on, and a Preferences pane item that will allow you to start and restart MySQL until you are blue in the face with the simple press of a button.
Your install should start like this:
- Download the
.dmg
- port uninstall
mysql5
andmysql5-devel
or whatever else you have installed - Add this to your
~/.bash_profile
:export PATH=$PATH:/usr/local/mysql/bin
- Restart your computer to make sure only your new MySQL 5.5’s daemon is running (when you uninstall the MacPorts, their daemons are still running until you kill them or restart) by typing:
ps aux | grep mysql
If you see anything running from /opt, your MacPort(s) aren’t uninstalled.
After you have restarted your computer:
- Fire up Terminal and type:
mysql -u root
- Run this query:
GRANT ALL ON *.* TO 'root'@'localhost' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
(replacing ‘mypassword’ with whatever you want your root password to be)
At this point, you should have a database that works. If not, read about symlink-ing .sock
files, etc here: How to install MySQL 5.5 on Mac OS X 10.7 Lion