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.

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’

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

#!/usr/bin/ruby

require 'rubygems'
require 'mysql'

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

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.

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$

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.

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

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

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

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$

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!!!

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.

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

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

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

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

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

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

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

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

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/

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

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

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.

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

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

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!

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

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

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

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.

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

Much obliged to you for sharing the delightfully concise solution!

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

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

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

That solved it for me too! Thanks so much!

Worked great on a fresh install of leopard.

Worked perfect on fresh install of Leopard

This:

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

works to me well, too!

That saved me some time!

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

Genius! Thank you very much.

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)

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!!!!

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

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…

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?

Awesome, worked perfectly. Thank you!

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

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.

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.

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

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

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.

@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?

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

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.

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.

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

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 :(

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

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

It works perfectly fine!
Thanks a lot!

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.

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.

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

sudo gem update —system

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.

The following worked for me:

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

I have the same problem, please help

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
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
mkmf.rb can’t find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

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

You can keep your 64 bit MySQL if you install ruby-mysql (the pure Ruby mysql gem)!

It is no longer at tmtm.org, but instead on github now:

http://github.com/tmtm/ruby-mysql

Moises, have you figured out why it doesn’t work. I have the same error that you do. I’m on Mac OS X Server. I’ve tried everything with no avail whatsoever. I have to admit I’m new to ruby and MySQL.

I tried all the above solutions and also “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”

but got the same error, I’m running Mac 10.6.3. Any Suggestions?

Thanks

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

it works! been looking for this one. thank you. =)

Thanks a lot for sharing, you saved my day :)

Awh, Al Chou – thanks a billion – you just saved me!

Michel’s suggestion worked for me, with the extra “config” argument:

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

Thanks everyone!

Thanks for posting this!

If you’re running RVM, this might not work for you. But, there’s a solution here:

http://rvm.beginrescueend.com/integration/databases/

I installed MAMP and ran this command. I’m running Snow Leopard.

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

Hm.

I did what you said and it installed fine but when i typed in

gem query

mysql did not appear on the list. Help?

“Outdated mysql gem. Upgrade to 2.8.1 or later” was a frustrating issue. Many people post that they have gotten this error, even though gem shows only mysql 2.8.1 installed. After pounding my head against the wall, I found that sometime ago I installed mysql 2.7 gem. Though gem did not list it (gem list), it turns out that programs calling mysql saw it first. The solution saw simple: Delete the mysql 2.7 directory in the gem library. After which, the programs ran.

ARCHFLAGS=“-arch x86_64” sudo gem install mysql — —with-mysql-config=/usr/local/mysql/bin/mysql_config

It worked for me when I run it without the “sudo”. Maybe this will help someone …

 
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
Copyright © 2002-2012 Ryan Grove. All rights reserved.
Powered by Thoth.