简体   繁体   中英

How to install mysql gem on Mac os 10.6?

i just installed MAMP on this iMac and the rubygems but when i run:

sudo gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config

gives me


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 mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

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 ERROR: could not find gem — locally or in a repository ERROR: could not find gem –with-mysql-config=/usr/local/mysql/bin/mysql_config locally or in a repository

how can i install this gem ?

使用以下它与我合作

brew install mysql

I found this and worked out perfectly:

you can go to http://www.tmtm.org/en/ruby/mysql/ to download the tar file, and run the command below

# ruby ./install.rb

to install the mysql.rb

Do you have the Xcode developer tools installed on Mac OS X? If not, I'd start there.

You can download them here: http://developer.apple.com/technologies/xcode.html

Once you've installed that, try again.

i'm still getting this


$ sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config 
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-config=/Applications/MAMP/Library/bin/mysql_config checking for mysql_ssl_set()... no checking for rb_str_set_len()... no checking for rb_thread_start_timer()... no checking for mysql.h... no checking for mysql/mysql.h... no * extconf.rb failed * Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.

Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby --with-mysql-config

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

You need the mysql development libs to compile it. If you were on linux you could use "yum install mysql-devel". Not sure about how to get them installed on a mac, but try downloading the connector libraries from here: MySql Connector Downloads

You may have to pass in a --with-mysql-libs option to point to the directory when the C libraries are unpacked to. Hope this points you in the right direction.

Or you can just put the libraries in the default directory: /usr/lib64/mysql

从mysql.com下载mysql-dev

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