Created
October 5, 2012 19:54
-
-
Save vargeorge/3841988 to your computer and use it in GitHub Desktop.
Mysql2 gem installation on OS X with MAMP installed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Use the following steps if you are looking to reuse MAMP mysql install for your rails app. This is how I set my machine. Hope its useful to others. | |
Steps: | |
1. Download mysql source code for the mysql version in your MAMP installation. | |
a. Find your MAMP version | |
$ system_profiler SPApplicationsDataType | grep -B5 "MAMP" | awk '/Version/ { print $2 }' | |
b. Find your MAMP mysql component version | |
Go to http://www.mamp.info/en/documentation/releases.html to find mysql component | |
version specific to your MAMP version | |
c. Download mysql source code | |
Go to http://dev.mysql.com/downloads/mysql/, choose Platform: "Source code" for the | |
closest version of mysql available. download using the link | |
"Generic Linux (Architecture Independent), Compressed TAR Archive" | |
d. extract mysql source | |
$ cd ~/Download | |
$ tar xvf mysql-5.5.28.tar.gz | |
$ cd mysql-5.5.28 | |
2. Install Mac Ports if not already installed. | |
download macports from http://www.macports.org/ and install. | |
# if you already have port installed then it's a good idea to keep it updated | |
# $ sudo port selfupdate | |
# $ sudo port upgrade outdated | |
3. install or update cmake | |
$ sudo port install cmake | |
4. for older versions of mysql modify or verify configure.cmkae file to avoid errors. | |
see the orginal line in comments and the changes uncommented below. | |
#LIST(REMOVE_DUPLICATES CMAKE_REQUIRED_LIBRARIES) | |
IF(CMAKE_REQUIRED_LIBRARIES) | |
LIST(REMOVE_DUPLICATES CMAKE_REQUIRED_LIBRARIES) | |
ENDIF() | |
5. build mysql | |
$ cmake . -DMYSQL_UNIX_ADDR=/Applications/MAMP/tmp/mysql/mysql.sock -DCMAKE_INSTALL_PREFIX=/Applications/MAMP/Library | |
$ make -j 3 | |
6. note the dylib names (*16.dylib or *18.dylib based on your version); copy dylibs to MAMP | |
$ ls libmysql/*.dylib | |
$ cp libmysql/*.dylib /Applications/MAMP/Library/lib/ | |
7. copy mysql header files to MAMP | |
$ mkdir -p /Applications/MAMP/Library/include/mysql | |
$ cp include/* /Applications/MAMP/Library/include/mysql | |
8. install mysql2 gem | |
$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql2 -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config | |
9. Find location of your gems | |
$ gem which rails | |
10. change the dylib linking to MAMP; change .dylib name and gem path as per values observed in step 6 and 9 | |
and version number of your mysql2 gem. make sure to use full path from / and not ~/path/to/file | |
$ sudo install_name_tool -change /Users/myusername/Download/mysql-5.5.28/libmysql/libmysqlclient.18.dylib /Applications/MAMP/Library/lib/libmysqlclient.18.dylib /Users/myusername/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle | |
11. cleanup the downloaded mysql source | |
$ rm -rf ~/Downloads/mysql-5.5.28* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment