Installing the MySQL Ruby Gem on OS X 10.6 (Snow Leopard)

This entry was posted September 18 2009 under Uncategorized.

11 comments

UPDATE: The advice in this post may work for some people, but I didn’t have complete luck until I installed MySQL via MacPorts, and then completely reinstalled Ruby and RubyGems via the Instructions at Hivelogic. Feel free to post a comment if you’re still having trouble.

Holy jumping crap am I ever sick of installing the MySQL gem. If I never have to do it again, it will be too soon. That being said, here’s what you get (as usual) if you

sudo gem install mysql

on Snow Leopard:


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

/usr/local/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=/usr/local/bin/ruby
	--with-mysql-config

Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1 for inspection.

This time it’s pretty simple. First of all, get rid of any old versions you have kicking around

sudo gem uninstall mysql

Next, install the newest MySQL package. Make sure you get the 64-bit version. For me it was 5.1.38. After that, and here’s the important, install Xcode from your Snow Leopard disc. Don’t skip this step! You may also need to update your RubyGems install:

sudo gem update --system

Finally, you just need to install the gem telling it where your config file is:

sudo gem install mysql -- --with-mysql-config=/usr/local/mysql-5.1.38-osx10.5-x86_64/bin/mysql_config

And that ought to do it!

Comments

thanks for saving me few hours..cheers m
hey..hit a snag finding the directory for rubygems on my 10.6 OS, looked as if it installed correctly after following your directions..but not able to find (on 10.6 operating system) when using the cd command in terminal..thought rubygems shipped standard 10.5 and later. Any suggestions on why I cant find? best m
Hey man, I actually ended up having to reinstall Ruby, Rubygems, and all my gems again after upgrading. You might have to do the same unfortunately.

Emerson on October 7th, 2009
No dice here - same error when I use your magic terminal string :-(
The advice in this post may work for some people, but I didn't have complete luck until I installed MySQL via MacPorts, and then completely reinstalled Ruby and RubyGems via the Instructions at Hivelogic (http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard/) I'll update my post.
tks for getting back to me right away..have ruby, rubygems, rails and my sql installed and working.unable to add a password to mysql ..keep getting "/usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)'" error...did u come across this at all?.am backtracking now..will try to reinstall SQL via macports like u mentioned...cheers m
hey sean, a little progress on my OS 10.6 -was able to set a password for mysql initially (after downloading everything from macport). Not able to create new databases from my macport installed mysql-directories are way off at everycorner despite resetting with .bash_login- Have you installed new databases using the mysql downloaded from macport? my directories are effed up. will try reinstalling everything but sql thru hivelogic like u recommended. tks
Make sure you're using the Macports version of everything, not the one you already installed. If you don't have important databases you can delete the copies of MySQL in /usr/local. From memory, I think you're looking for /opt/local/bin/mysql/mysqld_safe5 to start mysqld and /opt/local/bin/mysql5 to start MySQL.

kadeykin on April 5th, 2010
Leopard 10.5.8 has the same problem. This trick helps me to install the mysql gem. Thanks! Don't forger to install XCode!
Thanks! 10 web pages down before I got the right one: yours! The directions here were also helpful, http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/5cc87eaa98c1eadb/9e6635db4cab6baf?lnk=raot
Hivelogic was, is and might always be the best and only reference to install rails on osX; awesome.

Post a Comment







OMG Who?

I'm Sean Roberts, a 24-year-old Ruby on Rails developer currently working for Hamilton web design firm factor[e] design initiative. This is my blog about work and nerd stuff, and maybe a little bit about music and food too.

I'm On Twitter!

  • Can anyone recommend a good tailor in Hamilton? 1 week ago
  • Alphabits are a highly underrated cereal. Just saying. 1 week ago
  • Oh look, another good deal on a product that I need and can't find at a store around here. Do they ship to Canada? Of course not. 2 weeks ago
  • RT @JayHiggins: I'm going to be positive: Games big success, Ticats sold to billionare, LRT, Condo Dev at WH, Bettman retires 3 weeks ago
  • Wait, Hamilton has a football team? 3 weeks ago
  • Hooray for west harbour! I promise to not be sarcastic RE: government for a couple days. Probably. 3 weeks ago
  • More updates...