Installing the MySQL Ruby Gem on OS X 10.6 (Snow Leopard)
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
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.
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.
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.
I'll update my post.
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
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.
The directions here were also helpful, http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/5cc87eaa98c1eadb/9e6635db4cab6baf?lnk=raot

manette on October 7th, 2009
m