Install MySQL and MySQL Ruby gem on Snow Leopard, 64 bit
This is the source approach to get MySQL and MySQL Ruby gem working on Snow Leopard.
I assume you don't have any previous MySQL installations lying around, this guide covers the installation from scratch.
If you want to install your ruby gems in your self-contained home directory without using sudo, check the end of the article.
Install required software
Let's start by getting into a directory, I'll use ~/src.
By convention you may want to use /SourceCache aswell.
Download the latest MySQL source distribution and install Xcode from Snow Leopard DVD.
While you're downloading MySQL and installing Xcode you need to set your PATH environment variable correctly.
PATH Setup
Open a Terminal and verify what's your current PATH by doing this:
echo $PATH
This will return a string containing the current search paths, you have to make sure that's containing /usr/local/bin, /usr/local/sbin and /usr/local/mysql/bin.
Don't rely on your terminal application to set those paths; instead go ahead and edit/create the file .bash_profile (file that starts with a dot are hidden) in your home folder (~).
As a Textmate user I'll use the mate command to fire up my editor.
mate ~/.bash_profileInside this file, write:
PATH="/usr/local/bin:/usr/local/sbin:$PATH" # if not already present PATH="$PATH:/usr/local/mysql/bin" export PATH=$PATH
With this in place we are sure that we will find MySQL required files later.
If you don't want to reopen the terminal or switch to another tab, just execute:
source ~/.bash_profile
This will pickup changes to $PATH.
MySQL installation
Decompress the MySQL source:
tar xzvf mysql-5.1.40.tar.gz && cd mysql-5.1.40
Of course match the version number you downloaded, the latest as of this writing is 5.1.40.
Configure MySQL this way (one line):
CC=gcc CFLAGS="-arch x86_64 -O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-arch x86_64 -O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex --enable-thread-safe-client --enable-local-infile --enable-shared --with-plugins=innobase
Compile MySQL and install:
make && sudo make install
We are not done with MySQL yet, we need to install default tables and set up permissions:
cd /usr/local/mysql sudo ./bin/mysql_install_db --user=mysql sudo chown -R mysql ./var
We now have to auto start MySQL upon booting.
Create a file named
com.mysql.mysqld.plist
and add the following code in it:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>KeepAlive</key> <true /> <key>Label</key> <string>com.mysql.mysqld</string> <key>Program</key> <string>/usr/local/mysql/bin/mysqld_safe</string> <key>RunAtLoad</key> <true /> <key>UserName</key> <string>mysql</string> <key>WorkingDirectory</key> <string>/usr/local/mysql</string> </dict> </plist>
or see the script on github (raw).
Next move this file in the proper place with sudo and assign correct permissions:
sudo mv ~/src/com.mysql.mysqld.plist /Library/LaunchDaemons sudo chown root /Library/LaunchDaemons/com.mysql.mysqld.plist
Start up MySQL now with:
sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist
To stop MySQL manually do:
sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist
MySQL should be running (unless you stopped it, eh), it's time to change our MySQL root's password:
mysqladmin -u root password "mypassword"
Replace mypassword with your password.
Test MySQL:
mysqladmin -u root -p version
Write your password when asked and you should see some useful data.
Time to install the ruby mysql bindings gem.
MySQL Ruby gem setup
First, update rubygems.
sudo gem update --system
If this doesn't work for some reason or you get "Nothing to update" try this instead:
sudo gem install rubygems-update sudo update_rubygems
Time to build our gem, write:
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
And we are done, thanks for reading.
Extras
Not always is desiderable to install gems system-wide, so add this to your .bash_profile
export GEM_PATH="$HOME/.gem/ruby/1.8" export GEM_HOME="$HOME/.gem/ruby/1.8" PATH="$HOME/.gem/ruby/1.8/bin:$PATH" export PATH=$PATH
This will self-contain gem files and binaries in your home directory and you can install gems without using sudo.
Bonus
My entire .bash_profile:
export GIT_EDITOR="/usr/bin/mate -w" export EDITOR="/usr/bin/mate -w" export RAILS="$HOME/src/rails" export GEM_PATH="$HOME/.gem/ruby/1.8" export GEM_HOME="$HOME/.gem/ruby/1.8" # CAPP_BUILD, directory for built Cappuccino framework. export CAPP_BUILD="$HOME/src/cappuccino_framework" # Cappuccino jake branch. PATH="$CAPP_BUILD/Release/CommonJS/objective-j/bin:$PATH" PATH="$HOME/src/narwhal/bin:$PATH" # Normal stuff. PATH="$PATH:/opt/local/sbin" PATH="$PATH:/opt/local/bin" PATH="$PATH:/usr/local/mysql/bin" PATH="$HOME/.gem/ruby/1.8/bin:$PATH" # Finalize PATH export PATH=$PATH function parse_git_branch { ref=$(git symbolic-ref HEAD 2> /dev/null) || return echo "("${ref#refs/heads/}")" } RED="\[\033[0;31m\]" YELLOW="\[\033[0;33m\]" GREEN="\[\033[0;32m\]" PS1="$RED\$(date +%H:%M) \w$YELLOW \$(parse_git_branch)$GREEN\$ "
Related posts:
- Installing MySQL Ruby Gem in Snow Leopard Server
- CentOS “gem install mysql” problems, solution
- How to install pg (postgresql) gem on Snow Leopard, 64 bit
- Install Passenger (mod_rails) in Snow Leopard 64 bit
- How to install Sphinx search engine in Snow Leopard, x86 and x86_64
Enjoy this article?
Additional comments powered by BackType
August 28th, 2009 - 15:11
You are my new hero!!
Thanks for the tip
August 29th, 2009 - 03:59
Good post… one question, though. Do you use Passenger in development? If so, can you get PrefPane to work properly? Or really, just passenger altogether. My [appname].local stuff just died after the Snow Leopard install. Feel free to email if that’s easier. Thanks!
This comment was originally posted on The Life Of A Radar
August 29th, 2009 - 05:36
The url for limechat is wrong, it should be http://limechat.net/mac/ and not .org
This comment was originally posted on The Life Of A Radar
August 29th, 2009 - 09:35
Thanks Jason, fixed this!
This comment was originally posted on The Life Of A Radar
August 29th, 2009 - 09:45
Other Ryan:
I am currently working on something called driver: http://github.com/radar/driver. Just stuck at the moment on being able to select a directory, but progress is going good. I’ll let you know how it goes.
This comment was originally posted on The Life Of A Radar
August 29th, 2009 - 17:17
Thanks a lot! This saved me a lot of time!
After upgrading to Snow Leopard all of the ruby(and some others) header files were missing, so before actually compiling mysql install XCode from Optional Installations on your Snow Leopard DVD.
August 29th, 2009 - 18:39
thanks for the references to my blog, glad it was helpful to some
This comment was originally posted on The Life Of A Radar
August 30th, 2009 - 03:32
Thanks for posting this. That space after the first “<" on the first two lines wouldn't allow launchctl to load the file. You may want to update that. I also ran "plutil -convert binary1 com.mysql.mysqld.plist" and that gave me the debugging information I needed.
Thanks again!
August 30th, 2009 - 04:26
Cheers. Did save me some time and it worked first time.
+1 Awesomeness awarded to the Author :)
August 30th, 2009 - 05:57
Actually, the Passenger prefpane will work if you follow these instructions: http://josefernandez.tumblr.com/post/174433056/install-rubycocoa-on-snow-leopard
This comment was originally posted on Common Dream
August 30th, 2009 - 08:16
Thanks for posting that link. I was starting to really miss the pref pane as I thought about having to add all of my old hosts.
This comment was originally posted on Common Dream
August 30th, 2009 - 13:15
@Mike Farmer thanks for pointing this out, post was updated to reflect this information, I have to find a solution to this formatting problem.
August 30th, 2009 - 19:04
after some tinkering tag rendering in com.mysql.mysqld.plist should be fixed.
August 31st, 2009 - 22:35
That was a great post. Saved me a ton of time.
Thanks
Antonio
September 1st, 2009 - 03:47
I couldn’t get mongrel to work with script/server, even when i uninstalled and re-installed the gem.
The fix was to remove mongrel, cgi_multipart_eof_fix, fastthread, ferret, libxml-ruby, and rack, and then to re-install mongrel. Once I did that, and re-installed fastthread, ferret, libxml-ruby, and rack, it worked.
I think the issue was with uninstalling mongrel not also uninstalling cgi_multipart_eof_fix, but I also removed other gems (listed above) that sounded like they might be a part of mongrel.
Now I can do script/server and it works with mongrel.
This comment was originally posted on The Life Of A Radar
September 1st, 2009 - 03:49
By install and un-install above I mean doing so with gems:
1. gem uninstall mongrel cgi_multipart_eof_fix
2. gem uninstall fastthread ferret libxml-ruby rack
3. gem install mongrel
4. gem install fastthread ferret libxml-ruby rack
This comment was originally posted on The Life Of A Radar
September 3rd, 2009 - 16:34
To #1 Ryan: Passsenger Pref Pane just got updated. It’s working properly now, even though it’s still 32-bit.
Also, the MySQL package from MySQL tends to muck things up. So, I always go from MacPorts.
I documented the process here: http://blog.twg.ca/2009/09/livin-on-the-edge-ruby-rails-and-snow-leopard
Check it out…
This comment was originally posted on The Life Of A Radar
September 10th, 2009 - 01:23
Great tips, saved me some time. FYI, the mysql version has already bumped since your post, and the new one is mysql-5.1.38. Not a big deal, I’m sure, but since we’re going through the trouble you might as well have the latest and greatest. :)
September 10th, 2009 - 01:27
@Justin Leitgeb
yeah, good timing as I was looking at release notes, I’ll update the post, thanks :)
October 2nd, 2009 - 01:52
Thanks for your advice, saved me some time making it work 64 bit.
:-)
October 8th, 2009 - 12:08
There’s a weird problem while shutting down OSx, system takes 10-15 seconds with mysqld PID that’s still valid, you got the spinning round, so there’s something wrong… check this, launching in verbose mode and shutting your OSx down.
October 10th, 2009 - 23:20
Small nitpick.. Better to use /Library/LaunchDaemons rather than /System/Library/LaunchDaemons it’ll work the same but follows the convention of not messing in /System
Otherwise thanks for the ARCHFLAGS=”-arch x86_64″ tip =)
October 18th, 2009 - 10:39
Imposible install mysql gem. I follow all the instructions but always show “No definition for …” mesasges.
October 25th, 2009 - 08:03
I’ve heard there are some wildlife groups trying to get Apple to do more stuff with the actual S.L.’s lol. I don’t know- people are saying it’s good PR for Apple- they should jump on that.
This comment was originally posted on The Life Of A Radar
October 28th, 2009 - 17:23
Same here: all goes well until installing the gem;
Building native extensions. This could take a while…
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/Users/mmitchell/.rvm/ruby-1.8.6-p383/bin/ruby extconf.rb –with-mysql-config=/usr/local/mysql/bin/mysql_config
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=/Users/mmitchell/.rvm/ruby-1.8.6-p383/bin/ruby
–with-mysql-config
Gem files will remain installed in /Users/mmitchell/.rvm/gems/ruby/1.8.6/gems/mysql-2.8.1 for inspection.
Results logged to /Users/mmitchell/.rvm/gems/ruby/1.8.6/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
Anyone else getting this? Fixes?
October 31st, 2009 - 22:30
Sadly, I’m getting the same issue as Marcus.
Anybody have an idea?
November 1st, 2009 - 08:04
are you sure you have /usr/local/bin:/usr/local/sbin in your PATH?
November 1st, 2009 - 17:40
Yup. They’re in my PATH. Also, MySQL is running fine, so I know the install is good. Thanks for your help!
~ echo $PATH /Users/kevinsmith/.rvm/ruby-1.8.6-p383/bin:/Users/kevinsmith/.rvm/gems/ruby/1.8.6/bin:/Users/kevinsmith/.rvm/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/mysql/bin:/Users/kevinsmith/sdks/android-sdk-mac_x86-1.6_r1/tools ~ env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config Building native extensions. This could take a while... ERROR: Error installing mysql: ERROR: Failed to build gem native extension. /Users/kevinsmith/.rvm/ruby-1.8.6-p383/bin/ruby extconf.rb --with-mysql-config=/usr/local/mysql/bin/mysql_config 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=/Users/kevinsmith/.rvm/ruby-1.8.6-p383/bin/ruby --with-mysql-config Gem files will remain installed in /Users/kevinsmith/.rvm/gems/ruby/1.8.6/gems/mysql-2.8.1 for inspection. Results logged to /Users/kevinsmith/.rvm/gems/ruby/1.8.6/gems/mysql-2.8.1/ext/mysql_api/gem_make.out ~November 1st, 2009 - 18:12
did you update rubygems for your ruby version managed with rvm?
what’s your rubygem version? (gem -v)
I’m using the stock Ruby shipped with Snow Leopard, ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0], rubygems 1.3.5
November 1st, 2009 - 23:01
Figured out my issue. By default, rvm was not building the x86_64 version of Ruby (was defaulting to i386). To fix this, I added the following to ~/.rmvrc:
Then, I removed ~/.rvm/src/ruby-1.8.6-p383 and reinstalled 1.8.6 with rvm. After all that, the MySQL gem installed w/o a hitch.
I hope this helps anybody else with this same issue.
Thanks, Claudio, for your help and a great write up.
November 1st, 2009 - 23:02
very nice to know, hope your findings will help other peeps, thanks!
November 2nd, 2009 - 13:49
This is eerily similar to my own set up! Nice write up, thanks for sharing.
This comment was originally posted on The Life Of A Radar
November 7th, 2009 - 20:53
Thanks for the great help. But I get this error:
pastrufazio3:mysql riccardodebenedetti$ mysqladmin -u root -p version
Enter password:
mysqladmin: connect to server at ‘localhost’ failed
error: ‘Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)’
Check that mysqld is running and that the socket: ‘/tmp/mysql.sock’ exists!
What should I change?
November 7th, 2009 - 20:55
make sure you do not skip any step.
obvious question: did you started mysql with
?
Also note that there are instructions in the article on how to stop mysql after this command, so make sure it’s running.
November 7th, 2009 - 21:10
I launched and arrested Mysql but I received the error message
pastrufazio3:mysql riccardodebenedetti$ sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist
pastrufazio3:mysql riccardodebenedetti$ mysqladmin -u root -p version
Enter password:
mysqladmin: connect to server at ‘localhost’ failed
error: ‘Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)’
Check that mysqld is running and that the socket: ‘/tmp/mysql.sock’ exists!
Grazie mille
November 7th, 2009 - 21:27
can you see something like this
http://img.skitch.com/20091107-j1tcwixcskq276a3he58cajfh.png
in activity manager?
the mysql daemon isn’t started for some reason, but I have little info to understand what’s going on here.
November 7th, 2009 - 21:39
Here is the picture of the processes involved:
http://picasaweb.google.com/lh/photo/HmfPn0b0-PT3Emi7kuR31Q?feat=directlink
November 7th, 2009 - 22:02
you may have multiple versions of mysql installed, especially one 32bit, probably from macports or binary dmg image.
as stated in this guide I assumed that no prior versions of mysql are installed, you probably need to get rid of other versions running on your system
November 7th, 2009 - 23:22
I seemed to have them removed … Know any way to delete them deeply?
November 8th, 2009 - 00:21
I did a little ‘clean and everything works perfectly. Thank you
excellent help … big thanks
November 8th, 2009 - 01:31
glad you sorted that out Riccardo! happy hacking
November 8th, 2009 - 16:56
Hi Kain,
Awesome tutorial, I did everything and almost everything worked fine.
I could build and install mysql and it’s running nicely, but I really can’t install the mysql gem.
I’m with:
- Mac OS X 10.6.1
- Ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
- Gem 1.3.5
- MySQL 5.1.40
And I’m getting the following error while trying to install the mysql gem:
manoel-lemoss-macbook-pro:~ mlemos$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config 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 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=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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 /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.outAny ideias on how can I solve that?
November 8th, 2009 - 17:57
hi Manoel,
did you add the required directory in your PATH?
if you execute
in your terminal, what’s the output?
Also remember that if you did any changes to your. bash_profile you have to source it or open another terminal/tab in order to install the gem.
November 8th, 2009 - 22:44
Hi Kain,
Bingo, after checking PATH it did work. I mean, I got the “1 gem installed” message in the end, but some “no definition” while installing the documentation. I guess this is not an issue, right?
Thanks a lot for your great tutorial and support.
[]s
Manoel Lemos
November 9th, 2009 - 01:40
MySql works fine, but not as if the gem migrated gives me:
rake db:create
Couldn’t create database for {“reconnect”=>false, “encoding”=>”utf8″, “username”=>”root”, “adapter”=>”mysql”, “database”=>”depot_development”, “pool”=>5, “password”=>nil, “socket”=>”/tmp/mysql.sock”}, charset: utf8, collation: utf8_unicode_ci (if you set the charset manually, make sure you have a matching collation)
Compared to “uninitialized constant MysqlCompat: MysqlRes” seems a step forward but not to work.
November 9th, 2009 - 01:44
are you sure that your root user doesn’t have a password?
November 9th, 2009 - 08:22
Yes, no password. Access another database mysql with root user and no pw (use pgr Sequel pro)
November 11th, 2009 - 20:56
Thanks for the tutorial. I’m curious what you are doing at the end of your .bash_profile (after export PATH=$PATH). Looks like some cool stuff with Git. Would you mind giving some explanation to that as well?
November 11th, 2009 - 22:18
hi Andrew,
the git stuff is enhancing bash to see the branch on which I’m on when in a git project directory along with some colors, because having to type git branch everytime is annoying :)
November 15th, 2009 - 22:38
Да спасиб щас про это и у себя нацарапаю
This comment was originally posted on The Life Of A Radar
November 30th, 2009 - 00:50
I’m getting:
-bash: ./configure: No such file or directory
after the “Configure MySQL this way (one line):” line…any ideas?
November 30th, 2009 - 18:58
ah figured it out – i didn’t grab the mysql source so there was no/configure file. now i’m getting a weird error on the gem build:
My-MacBook-Pro:mysql me$ sudo env ARCHFLAGS=”-arch x86_64″ gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while…
Successfully installed mysql-2.8.1
1 gem installed
Installing ri documentation for mysql-2.8.1…
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
No definition for field_decimals
No definition for time_inspect
No definition for time_to_s
No definition for time_get_year
No definition for time_get_month
No definition for time_get_day
No definition for time_get_hour
No definition for time_get_minute
No definition for time_get_second
No definition for time_get_neg
No definition for time_get_second_part
No definition for time_set_year
No definition for time_set_month
No definition for time_set_day
No definition for time_set_hour
No definition for time_set_minute
No definition for time_set_second
No definition for time_set_neg
No definition for time_set_second_part
No definition for time_equal
No definition for error_errno
No definition for error_sqlstate
Installing RDoc documentation for mysql-2.8.1…
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
No definition for field_decimals
No definition for time_inspect
No definition for time_to_s
No definition for time_get_year
No definition for time_get_month
No definition for time_get_day
No definition for time_get_hour
No definition for time_get_minute
No definition for time_get_second
No definition for time_get_neg
No definition for time_get_second_part
No definition for time_set_year
No definition for time_set_month
No definition for time_set_day
No definition for time_set_hour
No definition for time_set_minute
No definition for time_set_second
No definition for time_set_neg
No definition for time_set_second_part
No definition for time_equal
No definition for error_errno
No definition for error_sqlstate
My-MacBook-Pro:mysql me$
any ideas?
December 1st, 2009 - 13:38
not an error
December 7th, 2009 - 02:49
@qrunchmonkey sudo gem uninstall mysql to clean, then follow the gem part of http://j.mp/3YdbHL be sure to set the config path appropriately
This comment was originally posted on Twitter
December 16th, 2009 - 16:42
Hey just wanted to mention that for me the trick was doing the whole “rubygems update” thingy in your post. I couldn’t install the mysql gem on rvm 1.9.1 and this did the trick ;) Now I’m onto the “incompatible character encodings: UTF-8 and ASCII-8BIT” issue but that’s another problem.
December 17th, 2009 - 07:11
Everything works until the last step (which is the most crucial and one that I have scoured 100s of websites for)..
The Last Step:
sudo env ARCHFLAGS=”-arch x86_64″ gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
The Result:
Building native extensions. This could take a while…
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/Users/ajayreddy/.ruby_versions/ruby-1.9.1-p243/bin/ruby extconf.rb –with-mysql-config=/usr/local/mysql/bin/mysql_config
checking for mysql_ssl_set()… yes
checking for rb_str_set_len()… no
checking for rb_thread_start_timer()… no
checking for mysql.h… yes
creating Makefile
make
gcc -I. -I/Users/ajayreddy/.ruby_versions/ruby-1.9.1-p243/include/ruby-1.9.1/i386-darwin9.7.0 -I/Users/ajayreddy/.ruby_versions/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/backward -I/Users/ajayreddy/.ruby_versions/ruby-1.9.1-p243/include/ruby-1.9.1 -I. -DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_H -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/mysql/include/mysql -arch x86_64 -fno-omit-frame-pointer -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno-common -O2 -g -Wall -Wno-parentheses -fno-common -pipe -fno-common -o mysql.o -c mysql.c
In file included from /Users/ajayreddy/.ruby_versions/ruby-1.9.1-p243/include/ruby-1.9.1/ruby.h:32,
from mysql.c:5:
/Users/ajayreddy/.ruby_versions/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/ruby.h: In function ‘INT2NUM’:
/Users/ajayreddy/.ruby_versions/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/ruby.h:464: warning: comparison is always true due to limited range of data type
/Users/ajayreddy/.ruby_versions/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/ruby.h:464: warning: comparison is always true due to limited range of data type
/Users/ajayreddy/.ruby_versions/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/ruby.h: In function ‘UINT2NUM’:
/Users/ajayreddy/.ruby_versions/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/ruby.h:472: warning: comparison is always true due to limited range of data type
mysql.c: In function ‘escape_string’:
mysql.c:290: error: lvalue required as left operand of assignment
mysql.c:290: error: lvalue required as left operand of assignment
mysql.c: In function ‘real_escape_string’:
mysql.c:434: error: lvalue required as left operand of assignment
mysql.c:434: error: lvalue required as left operand of assignment
make: *** [mysql.o] Error 1
Gem files will remain installed in /Users/ajayreddy/.ruby_versions/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/mysql-2.8.1 for inspection.
Results logged to /Users/ajayreddy/.ruby_versions/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
December 17th, 2009 - 07:46
So I figured out what the issue was…
It turns our there is a bug in version 243 of ruby 1.9.1.
Just update to the latest ruby (376 at this time) and it works fine.
Ajay
January 13th, 2010 - 02:58
BUMP what Ajay says below …
upgrade past Ruby 1.9.1 v243 and the make should build
December 24th, 2009 - 08:53
Install MySQL and MySQL Ruby gem on Snow Leopard, 64 bit « iCoreTech Research Labs: http://bit.ly/6OxaWu
This comment was originally posted on Twitter
January 5th, 2010 - 16:54
Hi kain
Thanks for your help
I get the same answer as rob :
dhcp-71:LaunchDaemons gg$ sudo env ARCHFLAGS=”-arch x86_64″ gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while…
Successfully installed mysql-2.8.1
1 gem installed
Installing ri documentation for mysql-2.8.1…
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
No definition for field_decimals
No definition for time_inspect
No definition for time_to_s
No definition for time_get_year
No definition for time_get_month
No definition for time_get_day
No definition for time_get_hour
No definition for time_get_minute
No definition for time_get_second
No definition for time_get_neg
No definition for time_get_second_part
No definition for time_set_year
No definition for time_set_month
No definition for time_set_day
No definition for time_set_hour
No definition for time_set_minute
No definition for time_set_second
No definition for time_set_neg
No definition for time_set_second_part
No definition for time_equal
No definition for error_errno
No definition for error_sqlstate
Installing RDoc documentation for mysql-2.8.1…
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
No definition for field_decimals
No definition for time_inspect
No definition for time_to_s
No definition for time_get_year
No definition for time_get_month
No definition for time_get_day
No definition for time_get_hour
No definition for time_get_minute
No definition for time_get_second
No definition for time_get_neg
No definition for time_get_second_part
No definition for time_set_year
No definition for time_set_month
No definition for time_set_day
No definition for time_set_hour
No definition for time_set_minute
No definition for time_set_second
No definition for time_set_neg
No definition for time_set_second_part
No definition for time_equal
No definition for error_errno
No definition for error_sqlstate
–
So I understand that mysql is correctly installed but what is the pb with those definitions ?
Thanks
Guillaume
January 6th, 2010 - 04:37
guessing, this is a C extension, and gem is trying to build documentation for those methods.
February 8th, 2010 - 01:01
I’m a newbie at this and hit a problem early on when doing the long one line configure:
-bash: ./configure: No such file or directory
Unlike Rob, I did download the source code into usr/local/mysql, and the tar ball unpacked to a directory mysql-5.1.43-osx10.6-x86_64. I cd into mysql-5.1.43-osx10.6-x86_64, and did the “CC=gcc CFLAGS=”-arch x86_64 -O3 -fno-omit-frame-pointer” etc long one line command.
What should I do now? Thanks!
February 8th, 2010 - 01:12
you haven’t downloaded the source, you got the binary tarball