简体   繁体   中英

Ruby on Rails: How do I install the mysql gem on 10.6.7 Mac OS X (64bit)

There seem to be a bunch of blogs and instructions out there to do this, but I think a large issue with them is that they don't specify architecture.. they assume 32bit... which makes me sad =(

Anyone know a good way to install the mysql connector / gem on 64bit snow leopard? Note: I already have mySQL, and it works just fine.

EDIT:

% sudo gem install mysql
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb



Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

Edit # 2

 % sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with-mysql-dir=/usr/local/mysql    

Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

I found it. I hope this helps other people who are having issues:

export ARCHFLAGS="-arch x86_64" ; sudo gem install --no-rdoc --no-ri mysql -v 2.7 -- --with-mysql-dir=/usr/local --with-mysql-config=/usr/local/mysql/bin/mysql_config

got it from this article:

http://www.milindspandit.org/blog/?category_name=technical

I used macports to install mysql, which provides the necessary header files to compile the mysql gem using gem install mysql . I know my mysql installation is 64-bit ( file /path/to/mysql reports Mach-O 64-bit executable x86_64 ). I assume the mysql gem is too. I hope this is what you're looking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM