FYI this is more for my reference than anything else. Use at your own risk.
My environment:
- Mac OS X 10.8.3
- Intel Core i5
- XCode 4.6.2 with command line tools
- RVM 1.20.12
- Ruby 2.0.0-p195 + default gems
- Rails 3.2.13 + associated gems
- MySQL 5.6.11 (64-bit) using mysql2 gem (version 0.3.11)
- Temporarily allow software installation from anywhere.
- Open System Preferences --> Security & Privacy.
- Click the lock icon at bottom-left. When prompted, enter your (administrator) password.
- Remember your current setting, i.e. "Mac App Store", "Mac App Store and identified developers" or "Anywhere".
- If it is not already selected, click the "Anywhere" radio button. Press "Allow From Anywhere" in the popup.
- Download MySQL.
- In your web browser, go to https://dev.mysql.com/downloads/mysql/
- Download the latest version of 64-bit MySQL as a DMG (as of this blog, it is "Mac OS X ver. 10.7 (x86, 64-bit), DMG Archive", the rest of the steps will use names based on this version).
- Install MySQL.
- Double-click the downloaded disk image, "mysql-5.6.11-osx10.7-x86_64.dmg".
- Double-click "mysql-5.6.11-osx10.7-x86_64.pkg". Install without any customization.
- Double-click "MySQL.prefPane". Install for all users on your computer.
- Double-click "MySQLStartupItem.pkg". Install without any customization.
- Eject the "mysql-5.6.11-osx10.7-x86_64" disk image.
- Restart MySQL.
- Open System Preferences --> MySQL.
- Press the "Stop MySQL Server" button. Enter your (administrator) password if prompted.
- If MySQL Server Instance is still running, you need to shut it down in Terminal.
- Open Terminal.
- Run this command:
$ sudo /usr/local/mysql/bin/mysqladmin shutdown
Enter your (administrator) password if prompted. - Press "Start MySQL Server" button. Enter your (administrator) password if prompted.
- Reset software installation permission.
- Open System Preferences --> Security & Privacy.
- Click the lock icon at bottom-left, if it is still locked. When prompted, enter your (administrator) password.
- Under "Allow applications downloaded from", choose your previous setting, i.e. "Mac App Store", "Mac App Store and identified developers" or "Anywhere" radio button.
- Close System Preferences.
- Start a new Terminal session (start a new tab with Cmd-T).
- Update permissions.
$ sudo chmod o-w /usr/local
- Install RVM with stable release of Ruby.
$ \curl -L https://get.rvm.io | bash -s stable --ruby
- Start a new Terminal session (start a new tab with Cmd-T).
- Update RVM settings.
$ source /Users/
/.rvm/scripts/rvm
$ rvm requirements - Verify RVM.
$ type rvm | head -n 1
rvm is a function - Verify Ruby.
$ rvm current
ruby-2.0.0-p195
$ ruby -v
ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.3.0] - Verify gem directory.
$ rvm gemdir
/Users/<home>/.rvm/gems/ruby-2.0.0-p195 - Update Rubygem (to be on the safe side).
$ gem update --system
- Install Rails.
$ gem install rails
- Verify Rails.
$ rails -v
Rails 3.2.13 - Verify GCC.
$ gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~28/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~28/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) - Verify MySQL.
$ mysql -V
mysql Ver 14.14 Distrib 5.5.20, for osx10.6 (i386) using readline 5.1 - Symlink MySQL dynamic library.
$ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
- Update mysql_config. (I use vim as my text editor.)
$ sudo vim /usr/local/mysql/bin/mysql_config
- Go to line 119.
- Copy-and-paste lines 119 and 120.
- Comment lines 119 and 120.
- Line 121: remove -Wno-null-conversion -Wno-unused-private-field
- Line 122: remove -Wno-null-conversion -Wno-unused-private-field
- So lines 119-122 should now be:
#cflags="-I$pkgincludedir -Wall -Wno-null-conversion -Wno-unused-private-field -Os -g -fno-strict-aliasing -DDBUG_OFF -arch x86_64 " #note: end space!
#cxxflags="-I$pkgincludedir -Wall -Wno-null-conversion -Wno-unused-private-field -Os -g -fno-strict-aliasing -DDBUG_OFF -arch x86_64 " #note: end space!
cflags="-I$pkgincludedir -Wall -Os -g -fno-strict-aliasing -DDBUG_OFF -arch x86_64 " #note: end space!
cxxflags="-I$pkgincludedir -Wall -Os -g -fno-strict-aliasing -DDBUG_OFF -arch x86_64 " #note: end space! - Save and exit.
- Install mysql2 gem.
$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql2 -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include
If mysql2 gem still fails to install: - Uninstall mysql2 gem.
$ gem uninstall mysql2 -a
- Delete MySQL's files and folders.
$ sudo rm /usr/local/mysql
$ sudo rm -rf /usr/local/mysql*
$ sudo rm -rf /Library/StartupItems/MySQLCOM
$ sudo rm -rf /Library/PreferencePanes/My*
$ sudo vim /etc/hostconfig
$ sudo rm -rf /Library/Receipts/mysql*
$ sudo rm -rf /Library/Receipts/MySQL* - Re-download and re-install MySQL.
- Go back to step 14 and continue from there.













