3

So I know that this question has been asked before, and I have looked through all of the previous answers and still can't find a solution. Hoping you all can help.

The setup: I am running Mac OS X 10.6 Server. I have used the built in MySQL install on web apps and it works great. Now I am trying to run a RoR app that requires MySQL.

So, whenever I enter

gem install mysql

it spits back the following error:

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

/Users/admin/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb --with-mysql-config=/var/mysql
*** 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=/Users/admin/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
    --with-mysql-config
extconf.rb:35:in ``': Permission denied - /var/mysql --cflags (Errno::EACCES)
    from extconf.rb:35:in `<main>'


Gem files will remain installed in /Users/admin/.rvm/gems/ruby-1.9.2-p180@rails3/gems/mysql-2.8.1 for inspection.
Results logged to /Users/admin/.rvm/gems/ruby-1.9.2-p180@rails3/gems/mysql-    2.8.1/ext/mysql_api/gem_make.out

So, through my research, I tried to specifically state the location of the MySQL install.

gem install mysql -- --with-mysql-config=/var/mysql

Unfortunately, with the same results.

Any ideas of where to go from here?

Thanks!

Kevin

Kevin Z
  • 341
  • 8
  • 16
  • Is there a reason you aren't using mysql2? – Steve Ross Apr 09 '11 at 19:30
  • http://stackoverflow.com/questions/2167598/mysql-install-error-failed-to-build-gem-native-extension – fl00r Apr 09 '11 at 20:06
  • http://stackoverflow.com/questions/354194/mysql-installation-troubles – fl00r Apr 09 '11 at 20:06
  • http://stackoverflow.com/questions/5219256/ruby-on-rails-mysql-installation-problem-on-ubuntu – fl00r Apr 09 '11 at 20:06
  • http://stackoverflow.com/questions/4613116/difficulties-installing-mysql-gem-on-ubuntu – fl00r Apr 09 '11 at 20:07
  • 2
    This is one of the most popular question on SO – fl00r Apr 09 '11 at 20:07
  • hey all...sorry, but none of the things you all suggested worked. However, I was able to find the answer, posted here for the next one who comes looking for the answer - worked like a charm! [Installing MySQL Ruby Gem on Snow Leopard Server](http://www.icoretech.org/2009/11/installing-mysql-ruby-gem-in-snow-leopard-server/) – Kevin Z Apr 10 '11 at 02:30

5 Answers5

5

Kevin,

This article may help you address your problem:

http://rapd.wordpress.com/2007/05/17/battle-against-ror-gem-install-mysql/

D. Simpson
  • 1,882
  • 17
  • 32
  • 2
    Awesome. Posted article did the trick for me. This line in particular from the article: `sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config` – kikuchiyo Dec 01 '11 at 01:53
1

On Mac OSX Lion 10.7 this command helped me install the mysql2 gem:

sudo gem install mysql2 -- --with-mysql-lib=/usr/local/Cellar/mysql55/5.5.30/lib --with-mysql-include=/usr/local/Cellar/mysql55/5.5.30/include/

Before this I did install mysql55 via brew like described above.

nuxxxx
  • 223
  • 2
  • 13
0
gem install mysql2 -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\include"'

Using the above worked with ruby Ruby 2.0 on Windows. I changed the library to just lib instead of lib\opt because lib\opt is not present in MySQL Server 5.5.

I picked the above command from a solution to this problem presented at: http://rorguide.blogspot.com/2011/03/installing-mysql2-gem-on-ruby-192-and.html

clami219
  • 2,958
  • 1
  • 31
  • 45
Pranay
  • 1
  • 1
0

I had success with this sudo gem install mysql -v '2.8.1' -- --with-mysql-config=/usr/local/mysql/bin/mysql_config but specifying the mysql version that I need

jacr1614
  • 1,250
  • 2
  • 14
  • 23
0

Your milage may vary, but here's what seemed to work for us. First, ensure you have the right libraries on there first (from Apple):

http://www.opensource.apple.com/other/MySQL-53.binaries.tar.gz

Install those via:

sudo tar -xvf ~/Downloads/MySQL-53.binaries.tar -C /

Then, for our 10.6 Server, the location of mysql_config was different:

gem install mysql -- --with-mysql-config=/usr/bin/mysql_config
Scott Corscadden
  • 2,831
  • 1
  • 25
  • 43
  • I installed mysql using homebrew and i am getting "Permission Denied" error. `gem install mysql -- --with-mysql-config=/usr/local/bin/mysql_config ERROR: While executing gem ... (Errno::EACCES) Permission denied - /Users/pratikkhadloya/.rvm/gems/ruby-1.8.7-p352/gems/mysql-2.8.1/COPYING` – Pratik Khadloya Aug 08 '11 at 16:52
  • Looks like, my previous gem install of mysql was done using sudo, so i uninstalled it and then reinstalled and it worked. – Pratik Khadloya Aug 08 '11 at 17:29