Skip to content

Instantly share code, notes, and snippets.

@dfasolin
Created June 30, 2011 01:15
Show Gist options
  • Save dfasolin/1055430 to your computer and use it in GitHub Desktop.
Save dfasolin/1055430 to your computer and use it in GitHub Desktop.
Installing MySQL2 gem on OSX 10.6
Uninstall your MySQL using the commands below
---------
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
---------
Now go and download the 64 bit version of the MySQL package – get the dmg rather than the gzip file.
The next step is to download the gem for your ruby/rails use
---------
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- \
--with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib \
--with-mysql-include=/usr/local/mysql/include
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
---------
The next error encountered is when I try to start the rails server using ‘rails s’
---------
~/.rvm/gems/ruby-1.9.2-p136/gems/mysql2-0.2.11/lib/mysql2.rb:7:in `require': dlopen(~/.rvm/gems/ruby-1.9.2-p136/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
---------
The answer to this problem is to run the following command…
---------
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib ~/.rvm/gems/ruby-1.9.2-p136/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle
---------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment