简体   繁体   中英

Installing MySQL with rails without Xcode

Is there anyway I could install MySQL gem for rails without Xcode? Many sites have mentioned XCode as optional requirement for installation. But Command line tools is installed.

I have installed rails , ruby, homebrew, MacPorts without XCode.But MySql gem could not be installed

Note: I have installed Command line tools for Xcode. But not full Xcode.

I have followed these references,

http://scotty-t.com/2012/04/02/intstalling-mysql-5-5-on-os-x-mountain-lion/

With setting path in bash_profile

But I keep on getting these errors while trying

sudo gem install mysql

Errors

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
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 --without-mysql-config

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

Should I install XCode first? Thanks in advance!

While you exec sudo gem install mysql , you're installing a gem which names mysql, not the database. This gem depende on a file named libmysql , which come with the mysql database.

In other words, you have to install mysql db on your machine first, then install the gem. Otherwise, the gem can't build because it can't find the file it need.

Since you have homebrew, you can install mysql db by exec brew install mysql . After that, sudo gem install mysql could work.

Do you have installed mysql-devel ? If not, try this

$ sudo yum install mysql-devel ;sorry it's for fedora

do it for lion, then

$ gem install mysql

If there still is error, try add a config path when you install the gem.

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