Here’s how to get the latest version of MySQL (5.0.51b as of this writing) working with the MySQL/Ruby gem and the Apple-supported version of Ruby that comes with Mac OS X Leopard. These instructions are scattered around the Internets in various places, but I’m sick of searching for them every time I need them so I’m compiling them here in a single place for convenience.

First, download and install MySQL for Mac OS X 10.5 (x86). Don’t install the x86_64 build or Ruby will refuse to speak to it. If you’ve already installed the x86_64 build, backup your databases, install the x86 build on top of it, and restore your databases.

Once you’ve got the correct build of MySQL installed, pop open a terminal and run the following to install the MySQL/Ruby gem:

sudo env ARCHFLAGS="-arch i386" gem install mysql -- \
  --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib \
  --with-mysql-include=/usr/local/mysql/include

That should do the trick.

Comments

I’ve been looking everywhere for this. Thanks a bunch.

Gravatar icon
DM
Wednesday August 06, 2008 @ 09:39 AM (PDT)

Hi,

I found your page through google and installed the ruby mysql gem on my mac with your line above. Thanks. After installing, I played around with it in irb on a mysql database that I have and it worked find. However when I tried to run a ruby script with it, the “require ‘mysql’” line fails and it doesn’t work:

./msql.rb:4:in `require’: no such file to load — mysql (LoadError)
from ./msql.rb:4

So, when I go back to irb and try to see what happened, irb works fine:

%irb
>> require ‘mysql’
=> true
>>

I’ve tried for a while to track this problem down (maybe it’s a path problem somewhere?)
But, haven’t found anything yet. Google doesn’t seem to be very helpful for this either.
Do you have any pointers? I’m assuming everything works for you. BTW, I’m running
10.5.4 on a 32-bit macbook.

Thanks for any help you can give.

-Jason

The test script from error above was:
#!/usr/bin/ruby

#puts `env`
require ‘mysql’

Gravatar icon
Jason
Tuesday September 02, 2008 @ 03:12 PM (PDT)

Try requiring RubyGems first (this is necessary since the mysql lib is a gem):

#!/usr/bin/ruby

require 'rubygems'
require 'mysql'
Gravatar icon
Tuesday September 02, 2008 @ 03:51 PM (PDT)

I was just looking back at your page since I got the script to work doing:
require ‘/usr/lib/ruby/user-gems/1.8/gems/mysql-2.7/mysql’

But, your require ‘rubygems’ is much better. I haven’t used gems that much… as
you can probably tell.

Thanks,
-Jason

Gravatar icon
Jason
Tuesday September 02, 2008 @ 03:58 PM (PDT)

Jason,

Same problem for me. If I don’t specify the absolute path I got the following:

NameError: uninitialized constant Mysql

Changing it to: require ‘/usr/lib/ruby/user-gems/1.8/gems/mysql-2.7/mysql’

Made everything work.

Gravatar icon
Friday September 12, 2008 @ 04:48 AM (PDT)

I’m getting the following error when trying to install – any ideas?

Macintosh-2:myequity greg$ sudo env ARCHFLAGS=“-arch i386” gem install mysql — —with-mysql-dir=/usr/local/mysql —with-mysql-lib=/usr/local/mysql/lib —with-mysql-include=/usr/local/mysql/include -V

WARNING: RubyGems 1.2+ index not found for:

RubyGems will revert to legacy indexes degrading performance.
Updating metadata for 69 gems from http://gems.rubyforge.org/
……………………………………………………………
complete
Building native extensions. This could take a while…
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.

/opt/local/bin/ruby extconf.rb install mysql — —with-mysql-dir=/usr/local/mysql —with-mysql-lib=/usr/local/mysql/lib —with-mysql-include=/usr/local/mysql/include -V
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… yes
checking for mysql_ssl_set()… yes
checking for mysql.h… yes
creating Makefile

make
/usr/bin/gcc-4.0 -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.3.0 -I. -DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_H -I/usr/local/mysql/include -I/usr/local/mysql/include -I/opt/local/include -fno-common -O2 -fno-common -pipe -fno-common -c mysql.c
mysql.c: In function ‘Init_mysql’:
mysql.c:2015: error: ‘ulong’ undeclared (first use in this function)
mysql.c:2015: error: (Each undeclared identifier is reported only once
mysql.c:2015: error: for each function it appears in.)
mysql.c:2015: error: syntax error before numeric constant
mysql.c:2018: error: syntax error before numeric constant
make: * [mysql.o] Error 1

Gem files will remain installed in /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out
Macintosh-2:myequity greg$

Gravatar icon
Greg H
Sunday September 14, 2008 @ 01:18 PM (PDT)

Thanks. I’d been ignoring the problem and using the default Ruby-based MySQL drivers until I saw they were going to be removed from Rails 2.2, this worked.

Gravatar icon
Monday September 22, 2008 @ 09:33 PM (PDT)

Thanks for posting this!

Gravatar icon
Saturday October 11, 2008 @ 11:47 AM (PDT)
I tried

sudo env ARCHFLAGS=“-arch i386” gem install mysql — \
—with-mysql-dir=/usr/local/mysql —with-mysql-lib=/usr/local/mysql/lib \
—with-mysql-include=/usr/local/mysql/include
without success, but everything was fine after adding
—with-mysql-config=/usr/local/mysql/bin/mysql_config

hoping that it could help someone

Gravatar icon
Michel
Friday October 17, 2008 @ 04:42 AM (PDT)

Thank you very much for your help. Worked as expected!

Gravatar icon
Friday October 24, 2008 @ 04:38 AM (PDT)

I really appreciate this as I’m tired of these errors!

Gravatar icon
Monday October 27, 2008 @ 03:12 PM (PDT)

Top man : worked first go !

Gravatar icon
Chris
Thursday October 30, 2008 @ 04:14 AM (PDT)

sudo env ARCHFLAGS=“-arch i386” gem install mysql — \
> —with-mysql-dir=/usr/local/mysql —with-mysql-lib=/usr/local/mysql/lib \
> —with-mysql-include=/usr/local/mysql/include
Password:
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 install mysql — —with-mysql-dir=/usr/local/mysql —with-mysql-lib=/usr/local/mysql/lib —with-mysql-include=/usr/local/mysql/include
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

  • 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
—with-mysql-dir
—with-mysql-include=${mysql-dir}/include
—with-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

Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.7/gem_make.out
Chinook1:~ marccantwell$

Gravatar icon
Marc
Sunday November 09, 2008 @ 07:09 PM (PST)

I downloaded the mysql version of mysql(duh…) like 5 months ago.

i was scared your tutorial wouldn’t work. BUT IT DOES. you are the man!!!

Gravatar icon
Sunday November 23, 2008 @ 06:07 AM (PST)

You might want to consider installing the pure Ruby MySQL interface from here:

http://www.tmtm.org/en/ruby/mysql/

It’s (at least to me) easier than re-installing mysql.

Simply install the latest version of rails. Download and install the Ruby MySQL interface and your good to go.

Gravatar icon
Monday November 24, 2008 @ 06:27 PM (PST)

thanks man. this is the only working solution that i could find among many purported ones which did not work. it must have been the 86_64 issue

Gravatar icon
ernest
Tuesday November 25, 2008 @ 11:38 PM (PST)

Working on a tiny machine and requiring I18N Rails 2.2 would be a big plus. I am currently on 2.1.2, using the ruby MySQL adpater. Any ideas how to install the shiny new MySQL adapter without first installing 3+GB of Xcode and a few MBs of MySql to compile a tiny adapter? Anything to copy over from a Mac that has that stuff installed?

Thanks,

Tom

Gravatar icon
Wednesday November 26, 2008 @ 07:14 AM (PST)

Thank you! After many hours of searching this fixed my problem.

Gravatar icon
Bora
Saturday November 29, 2008 @ 01:08 PM (PST)

Thanks a lot for pointing this out. Now I can use Rails 2.2.2. ;-)

Gravatar icon
Hugo
Tuesday December 02, 2008 @ 07:22 AM (PST)

Yeah after 6hours of trying different things and googling, I eventually came across your article. Sorted out everthing for me, thanks very much! :)

Gravatar icon
Tuesday December 09, 2008 @ 04:29 PM (PST)

Thanks a lot for this… Took me quite a lot of searching to reach here

Gravatar icon
Shiv Indap
Wednesday December 10, 2008 @ 05:41 PM (PST)

This did the job pretty well for me, of cpurse i had to install xcode tools 3 before that

#gem install mysql — —with-mysql-config=/usr/local/mysql/bin/mysql_config

Gravatar icon
Friday December 12, 2008 @ 11:21 PM (PST)

Thanks a lot—I googled and tried a lot after upgrading to Rails 2.2, this finally worked :-)

Gravatar icon
Saturday December 20, 2008 @ 05:34 PM (PST)

I did the following command, which worked:

sudo gem install mysql — —with-mysql-include=/usr/local/mysql/include —with-mysql-lib=/usr/local/mysql/lib —with-mysql-config=/usr/local/mysql/bin/mysql_config

Adapted from http://www.napcsweb.com/blog/2007/06/01/mysql-gem-on-osx/

Gravatar icon
Tuesday December 30, 2008 @ 04:48 AM (PST)

It’s more complicated. Still working on the solution.

Gravatar icon
Tuesday December 30, 2008 @ 04:57 AM (PST)

Adding —with-mysql-config=/usr/local/mysql/bin/mysql_config and it finally installed.

Gravatar icon
Monique Caron
Friday January 02, 2009 @ 03:06 PM (PST)

I just ran the command with my default MySQL version 5.0.67, and it “Successfully installed mysql-2.7”. I’m using Leopard 10.5.6. Thanks.

Gravatar icon
Friday January 02, 2009 @ 08:24 PM (PST)

I wasn’t sure what I installed, but my symlink from /usr/local/mysql explained it all:

> ls -l /usr/local/mysql
lrwxr-xr-x  1 root  wheel  24 Aug 13 14:20 /usr/local/mysql@ -> mysql-5.0.67-osx10.5-x86

Thanks!
- Andy

Gravatar icon
Andy
Tuesday January 06, 2009 @ 12:01 PM (PST)

Awesome, worked perfectly and saved me a bunch of time. thx!

Gravatar icon
Friday January 09, 2009 @ 12:57 PM (PST)

I came across this while trying to upgrade to rails 2.2 and this worked on the first try. Thanks for saving me a lot of time!

Gravatar icon
Sunday January 11, 2009 @ 08:35 PM (PST)

Running Apache2 from MacPorts and MySQL5.0.67 (x86), I had to run the following to get the install going:

sudo gem install mysql

# The standard install fails building the native extension, even with archflags set, so I build it mysql
cd /Library/Ruby/Gems/1.8/gems/mysql-2.7/

sudo env ARCHFLAGS="-arch i386" ruby extconf.rb --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include

Gravatar icon
Tuesday January 13, 2009 @ 09:31 AM (PST)

I’ve been killing myself looking for this. Worked like a charm!

Gravatar icon
Jared Howard
Monday January 19, 2009 @ 07:44 PM (PST)

As mentioned by Kristoph (thank you Kristoph!!!), the pure ruby interface can be found here:

http://www.tmtm.org/en/ruby/mysql/

(This is actually from the author of the ruby mysql gem, so you know you’re getting the right thing here).
This was SUPER easy to install. One thing to note though, the install instructions show:


$ ruby ./setup.rb
$ ruby ./test.rb hostname user passwd
$ ruby ./install.rb

But they should probably read:

$ ruby ./setup.rb
$ ruby ./test.rb hostname user passwd
$ sudo ruby ./install.rb

Otherwise the install script won’t have permission to write in the directory it’s trying to write to. Or at least, it didn’t on my machine…

I’m using XAMPP, and I suspect that this is the only way to use the XAMPP mysql with RoR.

Cheers!

-Steve

Gravatar icon
Steve
Tuesday January 27, 2009 @ 10:08 AM (PST)

Thanks for the post.
To make this work though, I had to kill default ruby installation and reinstall it from source,
if interested I used this link http://blog.bogojoker.com/2008/06/installing-ruby-187-on-mac-os-x-1053 in case if you will have problems with readline.

Gravatar icon
Monday February 02, 2009 @ 09:13 PM (PST)

worked on the first go!

Gravatar icon
Derek
Sunday February 15, 2009 @ 04:14 PM (PST)

In order for my install to work when installing MySQL 5 from MacPorts was to use the following line:

sudo env ARCHFLAGS=“-arch i386” gem install mysql — —with-mysql-dir=/opt/local —with-mysql-lib=/opt/local/lib/mysql5/mysql —with-mysql-include=/opt/local/include/mysql5/mysql

Gravatar icon
Matt
Tuesday February 17, 2009 @ 09:59 AM (PST)

Much obliged to you for sharing the delightfully concise solution!

Gravatar icon
Stephen Huey
Friday February 20, 2009 @ 09:15 AM (PST)

For those using Ruby on Rails, I just saw that there is a comment regarding this in database.sample.yml (in the config directory).

Gravatar icon
Stephen Huey
Friday February 20, 2009 @ 09:29 AM (PST)

Thanks a lot, copy/paste and it worked instantly.

Gravatar icon
Thursday February 26, 2009 @ 05:10 AM (PST)

I had different folders for MySQL:
mysql root: /opt/local/lib/mysql5
lib: /opt/local/lib/mysql5/mysql
include: /opt/local/include/mysql5/mysql

So I had to change the statement accordingly:

sudo env ARCHFLAGS=“-arch i386” gem install mysql — \
—with-mysql-dir=/opt/local/lib/mysql5 \
—with-mysql-lib=/opt/local/lib/mysql5/mysql \
—with-mysql-include=/opt/local/include/mysql5/mysql

Gravatar icon
Thursday March 05, 2009 @ 03:05 AM (PST)

That solved it for me too! Thanks so much!

Gravatar icon
Senz
Thursday March 05, 2009 @ 04:11 PM (PST)

Worked great on a fresh install of leopard.

Gravatar icon
Bryan Mahoney
Friday March 06, 2009 @ 09:09 AM (PST)

Worked perfect on fresh install of Leopard

Gravatar icon
Wednesday March 11, 2009 @ 08:55 PM (PDT)

dude you are a god.

Gravatar icon
Sunday March 29, 2009 @ 10:22 AM (PDT)

YOU ARE THE MAN!!!!!!

Gravatar icon
Saturday April 04, 2009 @ 06:24 AM (PDT)

This:

sudo gem install mysql — —with-mysql-config=/usr/local/mysql/bin/mysql_config

works to me well, too!

Gravatar icon
Fernando Gomes
Monday April 20, 2009 @ 11:00 AM (PDT)

That saved me some time!

Gravatar icon
Shashi Prabhakar
Sunday April 26, 2009 @ 03:00 PM (PDT)

sudo env ARCHFLAGS=“-arch i386” gem install mysql — —with-mysql-config=/Applications/MAMP/Library/bin/mysql_config

Gravatar icon
hacker_112
Sunday May 03, 2009 @ 08:11 AM (PDT)

THANK YOU! this works wonderfully!

Gravatar icon
Nearly MacHater
Wednesday May 06, 2009 @ 03:01 PM (PDT)

Genius! Thank you very much.

Gravatar icon
ricsrock
Thursday May 07, 2009 @ 12:54 PM (PDT)

Fixed my problems.

Gravatar icon
Steve
Saturday May 09, 2009 @ 12:31 AM (PDT)

for Ruby EE I did
sudo /opt/ruby-enterprise-1.8.6-20090421/bin/gem install mysql — —with-mysql-config=/opt/local/bin/mysql_config5

(make sure you substitute the version number for the correct one on your system, ie this bit → ruby-enterprise-1.8.6-20090421)

Gravatar icon
Wednesday May 13, 2009 @ 08:15 AM (PDT)

Thanks dude, mate or whatever. :B

Gravatar icon
Wednesday May 20, 2009 @ 06:04 AM (PDT)

Mate many thanx for that very useful post, I was trying every bloody combination till I found that page!
You Rock bro KEEP ER LIT!!!!

Gravatar icon
Andrew Shatnyy
Friday June 12, 2009 @ 01:40 AM (PDT)

Thanks, that’s exactly what I was looking for.

Gravatar icon
Serguei
Thursday June 18, 2009 @ 01:42 PM (PDT)

Worked perfectly.

Gravatar icon
Anon
Sunday June 21, 2009 @ 11:54 PM (PDT)

You are the man.

Gravatar icon
Mikhail
Tuesday June 23, 2009 @ 10:20 AM (PDT)

Thanks!

Gravatar icon
Wednesday June 24, 2009 @ 02:40 PM (PDT)

If you’re having trouble getting this to work after installing MySQL with MacPorts, check out this page here:

http://codeintensity.blogspot.com/2007/09/installing-ruby-mysql-gem-with-macports.html

After some searching, this finally worked for me…

Gravatar icon
Rob
Tuesday July 07, 2009 @ 08:13 PM (PDT)

Tried all the install options listed above -

Have upgraded to MYSQL 5.0.83 for PPC running rails 2.3 and keep getting this error

env: i386”: No such file or directory

if i do a straight gem install MYSQL

i get this ERROR: Failed to build gem native extension.

Is it the hard fact that I need to upgrade my very old computer?

Gravatar icon
Brian
Friday July 10, 2009 @ 10:01 AM (PDT)

Saved the day, and it also worked for MacPorts ruby.

Gravatar icon
Sunday July 12, 2009 @ 07:01 AM (PDT)

Awesome, worked perfectly. Thank you!

Gravatar icon
Shannon
Sunday July 12, 2009 @ 04:32 PM (PDT)

You’re the best!

Gravatar icon
Pi Too
Friday July 17, 2009 @ 12:59 PM (PDT)

Thanks!

Gravatar icon
Reem
Sunday July 26, 2009 @ 06:41 AM (PDT)

Ive tried almost everything.
Igot latest mysql up, but damn gam wont install.
Help me please !

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 —with-mysql-dir=/usr/local/mysql —with-mysql-lib=/usr/local/mysql/lib —with-mysql-include=/usr/local/mysql/include
can’t find header files for ruby.

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

Gravatar icon
no9
Saturday August 01, 2009 @ 09:00 AM (PDT)

I have installed all apps properly as far as I’m concerned, but seems can’t troubleshoot this one. Keeping receiving authentication error.
“Status: 500 Internal Server Error
Client does not support authentication protocol requested by server; consider upgrading MySQL client”

Anyone know a workaround to this? Would be highly appreciated.

Gravatar icon
Wednesday August 05, 2009 @ 12:00 AM (PDT)

On my new Mac Pro the Mysql files were not in the same location, so I needed to use:
sudo gem install mysql — —with-mysql-include=/opt/local/include/mysql5/mysql —with-mysql-config=/opt/local/bin/mysql_config5

I’m running 10.5, but it was copied over from a machine that was running 10.5, but upgraded from 10.4.

Gravatar icon
Wednesday August 05, 2009 @ 05:05 AM (PDT)

this solution worked great on my MBP, but its not working on my new Mac Pro nehalem 2.93.
I’ve tried this every which way.

I entered:

sudo env ARCHFLAGS=“-arch i386” gem install mysql — —with-mysql-dir=/usr/local/mysql —with-mysql-lib=/usr/local/mysql/lib —with-mysql-include=/usr/local/mysql/include —with-mysql-config=/usr/local/mysql/bin/mysql_config

I keep getting:

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 —with-mysql-dir=/usr/local/mysql —with-mysql-lib=/usr/local/mysql/lib —with-mysql-include=/usr/local/mysql/include —with-mysql-config=/usr/local/mysql/bin/mysql_config
can’t find header files for ruby.

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

Gravatar icon
will
Sunday August 09, 2009 @ 02:01 PM (PDT)

Thank you soo much.. it worked fine………. thank you !!!!!

Gravatar icon
Saturday August 29, 2009 @ 04:47 AM (PDT)

This worked well for me on Snow Leopard using 64-bit MySQL:

sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include

It’s not necessary to install 32-bit MySQL. You just have to explicitly set -arch x86_64 to tell the compiler to use 64-bit compilation and linking instead.

Gravatar icon
Michael Goff
Sunday September 06, 2009 @ 01:01 PM (PDT)

@Michael Goff: I tried your way on Snow Leopard and i still get the same error. It seems like no matter what I do, I get the error. Did you do anything special? Did you compile MySQL yourself? What version of MySQL did you install? Do you have to have mysql in your PATH?

Gravatar icon
Sunday September 13, 2009 @ 11:06 AM (PDT)

found good instructions here http://www.icoretech.org/2009/08/install-mysql-and-mysql-ruby-gem-on-snow-leopard-64-bit/

Gravatar icon
Jay
Saturday September 26, 2009 @ 07:24 AM (PDT)

I also had issues as I was using XAMPP and “gem install mysql” was complaining about missing mysql.h

I had to upgrade my XAMPP and additionally download the XAMPP developer tools.
Go to http://sourceforge.net/projects/xampp/files/ and downloaded:
xampp-macosx-1.7.2a.dmg
xampp-macosx-1.7.2a-dev.dmg

Of course first I had to remove/backup my existing XAMPP folder under /Applications/xampp

Then I installed the new version and after that the xampp-macosx-1.7.2a-dev.dmg developer pack.
this xampp-macosx-1.7.2a-dev.dmg contains the mysql.h header files and so on.

After that dev tools installation the XAMPP folder has a new folder called “include” which has all the mysql header files like mysql.h

Then the following command line worked for me:

sudo ARCHFLAGS=“-arch i386” gem install mysql — —with-mysql-dir=/Applications/XAMPP/xamppfiles/

Note I was pointing to the xamppfiles base-dir as the mysql-dir, because then all the paths are relative as if this would be the mysql root dir.

Gravatar icon
Friday October 09, 2009 @ 01:11 AM (PDT)

OK.

So I tried for about 2 hours to get mysql gem working. Here is the issue. I installed mysql 5.0 using a DMG file, so source. Updated ruby and gems and rails. All are up to date. So I tried the above solutions without any luck. What is the issue? Anyone do it the way I did it?

Here are the errors.

sudo env ARCHFLAGS=“-arch i386” gem install mysql — —with-mysql-dir=/usr/local/mysql-5.0.86-osx10.5-x86 —with-mysql-lib=/usr/local/mysql-5.0.86-osx10.5-x86/lib —with-mysql-include=/usr/local/mysql-5.0.86-osx10.5-x86/include —with-mysql-config=/usr/local/mysql-5.0.86-osx10.5-x86/include

Even tried using just mysql instead of the 5.0…

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb —with-mysql-dir=/usr/local/mysql-5.0.86-osx10.5-x86 —with-mysql-lib=/usr/local/mysql-5.0.86-osx10.5-x86/lib —with-mysql-include=/usr/local/mysql-5.0.86-osx10.5-x86/include —with-mysql-config=/usr/local/mysql-5.0.86-osx10.5-x86/include
mkmf.rb can’t find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

Any help would be great.

Gravatar icon
C W
Wednesday October 21, 2009 @ 05:38 PM (PDT)

For anyone that searches high and low. The fix for me was to install XCode from the Snow Leopard disk.

Gravatar icon
C W
Wednesday October 21, 2009 @ 06:41 PM (PDT)

Yeah, installing XCode fixed it for me too!

Gravatar icon
Anil
Sunday November 29, 2009 @ 08:39 AM (PST)

hey guys, tried every possible permutation of the install scripts to get this thing running with no joy sadly.

Server is running (default config) MYSQL 5.0.82 and database is located in /var/mysql, config lives here, /usr/bin/mysql_config

I just can’t seem to win. Endless “Could not create Makefile” problems.. doing my head in :(

Gravatar icon
Robert Lincolne
Thursday January 14, 2010 @ 05:05 PM (PST)

Hi Guys,
The following is the error i get while am installing sqlite. Can u guys help me
C:\>gem install sqlite3-ruby -v 1.2.3
Building native extensions. This could take a while…
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.

C:/Ruby/bin/ruby.exe extconf.rb
checking for fdatasync() in -lrt… no
checking for sqlite3.h… no

make
‘make’ is not recognized as an internal or external command,
operable program or batch file.

Gem files will remain installed in C:/Ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1
.2.3-x86-mingw32 for inspection.
Results logged to C:/Ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.3-x86-mingw32/
ext/sqlite3_api/gem_make.out

Gravatar icon
anji
Monday January 18, 2010 @ 09:28 AM (PST)

Can u guys help me, mysql not installing
C:\>gem install mysql
Successfully installed mysql-2.8.1-x86-mingw32
1 gem installed
Installing ri documentation for mysql-2.8.1-x86-mi

No definition for next_result

No definition for field_name

No definition for field_table

No definition for field_def

No definition for field_type

No definition for field_length

No definition for field_max_length

No definition for field_flags

Gravatar icon
anji
Monday January 18, 2010 @ 09:36 AM (PST)

It works perfectly fine!
Thanks a lot!

Gravatar icon
Gustavo Arjones
Thursday January 21, 2010 @ 07:08 AM (PST)

Same as Robert Lincolne, I’m on Snow Leopard Server, which has MySQL installed out of the box, but can’t seem to find the right combination of flags to make this work. And yes, I have all the development tools installed.

Gravatar icon
Trejkaz
Monday January 25, 2010 @ 05:33 PM (PST)

OK, I figured it out. For the benefit of others, you need to get this:

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

And unpack it to the root of your main volume. Basically the libraries are missing from Mac OS even though it includes the server and the client out of the box (…why, Apple?…) This restores the missing files, and then the default gem command worked for me.

Gravatar icon
Trejkaz
Monday January 25, 2010 @ 06:14 PM (PST)

I was finally able to get mysql gem installed using the commands above, after I did:

sudo gem update —system

Gravatar icon
Daniel
Tuesday February 02, 2010 @ 07:28 PM (PST)

Simply add /usr/local/mysql/bin to your path or whatever the /path/to/mysql/bin is… on mac, this is usually your .profile file in your home directory. On mac, I recommend having mac ports installed if you have any missing unix tools that are necessary. Also any “No definition for”… statements that show up after the gem is already installed have to do with the documentation and shouldn’t be of any concern.

Gravatar icon
Tuesday February 23, 2010 @ 08:03 PM (PST)

The following worked for me:

sudo env ARCHFLAGS=“-arch x86_64” gem install mysql — —with-mysql-config=/Applications/MAMP/Library/bin/mysql_config

Gravatar icon
Monday March 01, 2010 @ 10:06 PM (PST)

Made use of the following tutorial to include mysql headers and library.

Gravatar icon
Thursday March 04, 2010 @ 04:30 AM (PST)
New comment

required, won't be displayed

optional

Don't type anything here unless you're an evil robot:


And especially don't type anything here:

Basic XHTML (including links) is allowed, just don't try anything fishy. Your comment will be auto-formatted unless you use your own <p> tags for formatting. You're also welcome to use Textile.

Copyright © 2002-2010 Ryan Grove. All rights reserved.
Powered by Thoth.