Installing mysql2 gem on Mac os x Lion

孤街浪徒 提交于 2019-12-03 08:41:31
Rafael Oliveira

Don't know if this will help, but lemme try.

To make mysql2 gem working under my OSX Lion, running Ruby 1.8.7:

Install mysql - Download mysql-5.5.14-osx10.6-x86_64

Create an alias inside .bash_profile to mysql e MySQLCOM

  • alias mysql="/usr/local/mysql/bin/mysql"
  • alias mysqld="sudo /Library/StartupItems/MySQLCOM/MySQLCOM"

Install gem 'mysql2', '0.3.6'

Create this symbolic link:

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
  1. From terminal $ locate mysql_config so you can find path to it
  2. Then $ sudo gem install mysql2 -- –with-mysql-config=/path/to/mysql_config

I got this installed in the system Ruby (1.8.7 on Lion) as follows:

  1. Install 64-bit MySQL 5.5.19 64-bit from the .dmg
  2. Add /usr/local/mysql/lib to your DYLD_LIBRARY_PATH (I prefer this to the symbolic link solution but they should be equivalent). I did this in my .bash_profile via:

    export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"
    
  3. Execute:

    env ARCHFLAGS="-arch x86_64" sudo gem install mysql2 -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include --with-mysql-config=/usr/local/mysql/bin/mysql_config
    

I solved this issue by reinstalling ruby--which appears to be required since the compilers are updated in Lion.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!