Very Simple Homebrew MySQL and Rails

Mike_bishop By Mike Bishop

Install Homebrew

ruby -e "$(curl -fsS http://gist.github.com/raw/436471/install_homebrew.rb)"

Install Xcode

http://developer.apple.com/technologies/xcode.html

Install GIT

brew install git

Install MySQL

brew install mysql

Initialize MySQL

Install Databases

mysql_install_db

Tell MySQL how to behave

Place this in /etc/my.cnf

[mysqld]
#Max packetlength to send/receive from to server.
max_allowed_packet=64M
#socket = /var/mysql/mysql.sock
character-set-server = utf8
default-character-set = utf8

#This option makes InnoDB to store each created table into its own .ibd file.
innodb_file_per_table

[mysql]
default-character-set = utf8

[client]
#socket = /var/mysql/mysql.sock
default-character-set=utf8

Setup the startup script

cp /usr/local/Cellar/mysql/5.1.47/com.mysql.mysqld.plist ~/Library/LaunchAgents

launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist

Get rid of Apple Supplied Gems

sudo rm -Rf /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8

Or if you are paranoid… just move em out.

sudo rm -Rf /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8 ~/Desktop/OldGems/

Update Ruby Gems

sudo gem update --system && sudo gem clean

Install Rails

sudo gem install rails

Install MySQL Gem

sudo env ARCHFLAGS="-arch x86_64" gem install mysql --no-rdoc --no-ri -- --with-mysql-config=/usr/local/bin/mysql_config

Test it out

cd ~/Desktop
rails -d mysql testapp
cd testapp
rake db:create
script/generate scaffold car name:string
rake db:migrate
script/server

Then surf to: http://localhost:3000/cars

Voila!

Respect to: Justin Ball

URL: http://theablefew.com/blog/very-simple-homebrew-mysql-and-rails