CS142: Web Programming and Security

Install Ruby on Rails and MySQL on Mac

Mac OSX 10.5 Leopard (Recommended)

To get started, you need to install XCode, but note that you will NOT be developing in XCode, you just need to have it installed. You can grab the dmg file here: http://developer.apple.com/technology/xcode.html. I recommend the iPhone version if you have any interest in doing iPhone dev at any point. Also, you'll have to sign up for a free ADC account to download XCode.

Since Leopard includes an installation of Ruby on Rails by default all that is required is updating your installation of Ruby, Gems (Ruby's packaging mechanism) and Rails. Follow the following instructions in order in your Terminal:

sudo gem update
may see ERRORs all over the place, but really ok
sudo gem update --system
updates to latest version of ruby, 1.8.6
sudo gem install rails --include-dependencies
Updates Rails to the latest version

Now that you are done installing Ruby on Rails let's install MySQL.

  1. First download the latest version of MySQL here: http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg. Make sure you choose 10.5 and the right architecture and processor level for your computer (Most likely x86 and NOT 64).
  2. Install all three things in the package, in this order: mysql-{version}-osx10.5-x86.pkg, MySQL.prefPane, MySQLStartupItem.pkg
  3. Add the following line to your .bash_profile file in your home directory (use some command line text editor from your Terminal like: vim .bash_profile)
    	export PATH=${PATH}:/usr/local/mysql/bin
    	
  4. Restart your Terminal app
  5. Run the following command in your Terminal to get the mysql Ruby Gem to properly install:
    sudo env ARCHFLAGS="-arch i386" gem install mysql -- \
      --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib \
      --with-mysql-include=/usr/local/mysql/include

Mac OSX 10.4 Tiger

Please upgrade to Leopard if you can, since we don't have Tiger on any machines that are accessible to us it will be hard for us to support. Follow the instructions at hivelogic to get Ruby on Rails and MySQL installed on your machine, make sure you are using Rails version 2.2.2.

These instructions have not been tested, so if you find problems and work arounds please email Indy and I'll update the instructions accordingly.

What's next?

  • There are plenty GUI applications for exploring MySQL. We recommend MySQL Adminstrator, and MySQL Query Browser for all platforms. There may be nicer interfaces for Mac OSX out there, but we will only be supporting MySQL Administrator and MySQL Query Browser.
  • You can also explore the database by invoking the following command:
    mysql -u root -D project6_development
    This will enter a MySQL command shell where you can type SQL statements (don't forget to terminate them with semicolons). Type exit when you are done.
  • To start and stop mysql from the command line in MacOS X Leopard, use "sudo /Library/StartupItems/MySQLCOM/MySQLCOM [start/stop]"