Tuesday, January 4, 2011

Completely Remove MySQL on Mac OS X

I was getting my Mac ready to do some Rails development with a MySQL database and I ran into a problem installing MySQL 5.5.8 on OS X 10.6.5.  I downloaded the .DMG and ran through the mysql-5.1.54-osx10.6-x86_64.pkg installer without a problem.  However, after installing the server and the MySQL.prefPane I could not start the server from the preference pane.  Then I noticed that the installer did not run scripts/mysql_install_db as part of the post installation process.  Well my first thought is that I obviously did something wrong so I thought I'd remove MySQL and start over again.  So, I did some googling and found these steps to completely remove MySQL:

  1. sudo rm /usr/local/mysql
  2. sudo rm -rf /usr/local/mysql*
  3. sudo rm -rf /Library/StartupItems/MySQLCOM
  4. sudo rm -rf /Library/PreferencePanes/My*
  5. (Edit /etc/hostconfig) sudo vi /etc/hostconfig (Remove line MYSQLCOM=-YES)
  6. sudo rm -rf /Library/Receipts/mysql*
  7. sudo rm -rf /Library/Receipts/MySQL*
  8. sudo rm -rf /var/db/receipts/com.mysql.*

Apparently the receipts are in a different location for the newer versions of MySQL so line #8 was added to clean them out as well.  Remember, these steps will completely remove MySQL and any data residing in the default locations.

So, back to my struggles.  I ended up installing MySQL 5.5.8 a couple of times using different archives with the same result so this removal process came in real handy...I almost made a script out of it.  After getting pretty frustrated with version 5.5.8 I ended up installing version 5.1.54 without a problem and it is running fine!?!?!