Installing MySQL gem on OSX 10.6.8

17 views
Skip to first unread message

Chris Ell

unread,
Nov 15, 2011, 12:05:33 PM11/15/11
to LearnRuby101
Hey everyone,

Not sure if there is a solid solution to this problem but I've been
searching everywhere for help. I'm trying to learn the deployment
process of a Ruby on Rails application through "Agile Web Development
with Rails" and I'm working on setting up the local deployment of the
application. I'm currently stuck on the installation of the MySQL gem
to create a local database for the app to run off of. When I run "gem
install mysql" i get the following error:

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

/Users/isite/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... 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=/Users/isite/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
--with-mysql-config
--without-mysql-config
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mlib
--without-mlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-zlib
--without-zlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-socketlib
--without-socketlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-nsllib
--without-nsllib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mygcclib
--without-mygcclib
--with-mysqlclientlib
--without-mysqlclientlib


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

I've read lots of posts that say you need to pass the config file to
the install (located at /usr/local/mysql/...etc) but currently there
is no MySQL director in the /usr/local/ dir. Although when i try to
run the latest MySQL installer (5.5.17), It prompts me that there is a
newer version already installed (I have XCode installed so i've been
told that MySQL install through that).

Not sure where to go from here or if this is specific enough to get
any help, but feedback would be greatly appreciated.

Thanks!

Mat Schaffer

unread,
Nov 15, 2011, 12:27:30 PM11/15/11
to learnr...@googlegroups.com
These days I usually get mysql via homebrew similar to what's here http://www.frederico-araujo.com/2011/07/30/installing-rails-on-os-x-lion-with-homebrew-rvm-and-mysql/

I'm guessing the MySQL Installer puts the mysql development libraries in a funny place. What happens when you run this?

  mysql_config --include

If you get something like "-I/usr/some/stuff/here/mysql/5.5.14/include" then you can try this command to install the gem:

  gem install mysql -- --with-mysql-config=`which mysql_config`

If you can't run the first command at all, the mysql installer might have not installed the headers. If so I'd recommend trying the homebrew route. If you already have Xcode installed you can skip ahead to just after that part of the article.

Let me know how you make out,
Mat

Chris Ell

unread,
Nov 15, 2011, 1:05:01 PM11/15/11
to LearnRuby101
Sounds good, Yeah the mysql_config command isn't found, so i'll take a
look at the article and try that out.

Thanks for the quick response, I'll keep you updated with how it goes.

On Nov 15, 12:27 pm, Mat Schaffer <m...@schaffer.me> wrote:
> These days I usually get mysql via homebrew similar to what's herehttp://www.frederico-araujo.com/2011/07/30/installing-rails-on-os-x-l...

Mat Schaffer

unread,
Nov 15, 2011, 1:06:48 PM11/15/11
to learnr...@googlegroups.com
Cool, just make sure the MySQL you already isn't installed is stopped. Otherwise you may hit a port conflict when you start the homebrew-installed server,
-Mat

Chris Ell

unread,
Nov 15, 2011, 2:18:09 PM11/15/11
to LearnRuby101
Hey,

Everything worked out well, the MySQL gem finally installed but now I
think I ran into what you just mentioned because when i try to run the
command "mysql" i get:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/tmp/mysql.sock' (2)

Not sure if this is the same problem but it seems like it is (sorry,
I've only been programming for a few months now and especially working
at root level like this is real new to me). I'm not sure if anything
went wrong during the installation process but I also noticed my
TextMate alias stopped working (ie. mate Gemfile).

Thanks for all your help so far, Definitely owe you a beer.

Chris Ell

unread,
Nov 15, 2011, 2:39:31 PM11/15/11
to LearnRuby101
sorry, i should mention I tried the:

if you have problems with mysql "cannot connect to /tmp/mysql.sock"
then create a file /usr/local/etc/my.cnf and add this:

[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
bind-address = 127.0.0.1
port = 3306
socket = /tmp/mysql.sock

at the bottom of the link you provided.

Not sure if any configuration is needed to that solution.

Mat Schaffer

unread,
Nov 15, 2011, 6:10:10 PM11/15/11
to learnr...@googlegroups.com
Is mysql definitely running? `ps uwax | grep mysql` should help there.
-Mat

Chris Ell

unread,
Nov 15, 2011, 6:40:52 PM11/15/11
to learnr...@googlegroups.com
Yup, finally got it all worked out. Think it had to do with the path to MySQL. Working on setting up the deployment server tomorrow. Thanks or all your help. 

Chris Ell
Interactive Developer @ I-SITE
Sent from my iPhone

Mat Schaffer

unread,
Nov 15, 2011, 8:39:08 PM11/15/11
to learnr...@googlegroups.com
Nice!

Don't forget about heroku. I use it for damn near everything these days. 

-Mat

Chris Ell

unread,
Nov 15, 2011, 9:44:16 PM11/15/11
to learnr...@googlegroups.com
Yeah, the first time I deployed I used heroku. In fact I'm messing around with it at the moment on my personal computer getting used to that and Git. However I wast sure what the deal was using it commercially without getting a plan. We currently have a dedicated server that we run and was looking to set up that one (and just learn more about servers in general) but if heroku is a viable option I'd love to hear more about it. 


Chris Ell
Interactive Developer @ I-SITE
Sent from my iPhone

Mat Schaffer

unread,
Nov 15, 2011, 10:34:57 PM11/15/11
to learnr...@googlegroups.com
Heroku is definitely viable for commercial work. The only time it doesn't work too well is if the app needs access to something behind a firewall. You can't just map IPs since heroku apps share servers.

But doing it by hand a few times is a good learning experience too. Have fun!

-Mat
Reply all
Reply to author
Forward
0 new messages