RoR3 and MySQL error: dyld: Symbol not found: _mysql_init - mysql

I am troubleshooting a problem with MySQL for my Ruby on Rails 3.0.5 application, Mac OS X 10.6.
I installed MySQL version 5.1 and I am getting this error:
dyld: lazy symbol binding failed: Symbol not found: _mysql_init
Referenced from: /Users/manny/.gem/ruby/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Expected in: flat namespace
dyld: Symbol not found: _mysql_init
Referenced from: /Users/manny/.gem/ruby/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Expected in: flat namespace
Trace/BPT trap
I tried to install MySQL v5.5, but the error still occurs. I installed MySQL from a .dmg.

You don't need to remove MySQL and reinstall it, I did just with the following commands. It's very simple to do from your terminal and will solve your issues:
rvmsudo ARCHFLAGS="-arch x86_64" gem install mysql2 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config --with-opt-lib=/usr/local/mysql/lib
I hope this might help you to solve the issues.

Give the following a go...
# Use mysqldump to backup your databases to text files!
# Stop the database server
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
Then...
# Install Homebrew if you have not got it.
brew install mysql
export ARCHFLAGS="-arch i386 -arch x86_64" gem install mysql -- --with-mysql dir=/usr/local \ --with-mysql-config=/usr/local/bin/mysql_config
That's assuming your homebrew prefix is /usr/local
Otherwise you could always download the required MySQL Version, install and run the following...
env ARCHFLAGS="-arch x86_64" gem install --no-rdoc --no-ri mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Be sure to have your paths set in you bash and dont go about mysql2 0.2.7 with Rails.

I tried numerous solutions found on the net. Finally I decided to do it another way. Reason for this is that most solution come with fixes for binding problems, that can be related back to troubles during the installation. Just a matter of authorization.
First removed the DBI and DBD / DBD::mysql files and folders from the Perl libraries
folder in:
/Library/Perl/5.16/darwin-thread-multi-2level
After that I started clan via a sudo
sudo cpan
In there I installed first DBI and after that DBD::mysql
install DBI
install DBD::mysql
And everything finally worked! Hope this helps, someone. A simple solution. It did cost me 2 days to debug and figure out.

Related

Uninstall MySQL in WSL

How do I uninstall MySQL in WSL?
I have version 5.7.4 installed. After reading over the changes for upgrading to the latest 5.7.x version so I could upgrade to 8.0 (there's a minimum requirement of 5.7.9 to upgrade to 8.0), I figured it would be easier to just uninstall MySQL and start over (I have nothing worth saving from playing around with it previously).
I tried running the following commands (as per this post and this one) and got the following responses:
$ sudo apt remove mysql mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package mysql
$ sudo apt-get remove --purge *mysql*
zsh: no matches found: *mysql*
$ sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
zsh: no matches found: mysql-server-core-*
After running those, I'm still able to start and stop my server with the following commands (note that these are not necessarily the usual systemd commands because I'm in WSL2):
sudo /etc/init.d/mysql start
mysqladmin -u root -p shutdown
Unsure if this is relevant, but even when the server is running I'm not seeing the socket when I enter sudo find / -type s as suggested by this post.
I'm wondering it'd be okay to just delete what files I can find manually, but that seems like a bad idea
/var/lib/mysql/
/usr/share/mysql/
/usr/lib/mysql/
The problem was using zsh as a shell. I successfully removed MySQL with sudo apt-get remove --purge '*mysql*'

How to install mysql workbench in debian buster?

I tried the following commands :
sudo dpkg -i mysql-apt-config_0.3.5-1debian8_all.deb
sudo apt-get update
sudo apt-get install mysql-workbench-community
but on searching mysql-workbench-community
sudo apt-cache search workbench | grep mysql
returns nothing.
And
sudo apt-get install mysql-workbench-community
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package mysql-workbench-community
What to do ?
I did manage to install without issues MySQL Workbench 8.0.19 version from an Ubuntu package in Debian Buster, with the command:
sudo dpkg -i mysql-workbench-community_8.0.19-1ubuntu18.04_amd64.deb
First you must download the package from the mysql website:
Just select Ubuntu Linux operating system and 18.04 version (19.10 version had broken dependencies) .
Hope this helps.
MySQL Workbench mysql-workbench has been removed from Debian buster due to a release-critical bug.
https://tracker.debian.org/pkg/mysql-workbench
https://tracker.debian.org/news/943250/mysql-workbench-removed-from-testing/
https://bugs.debian.org/867943
https://bugs.mysql.com/bug.php?id=89898
It can also be installed from Snapcraft. I haven't used it that much, but apparently it works. First you need to enable snapd:
$ sudo apt update
$ sudo apt install snapd
$ sudo snap install core
Then install MySQL workbench (community edition):
$ sudo snap install mysql-workbench-community
If you want to delete it, simply:
$ sudo snap remove mysql-workbench-community
I was able to install the latest version of MySQL Workbench (as of this writing) on Debian 10 using this method:
sudo apt install ./mysql-workbench-community_8.0.23-1ubuntu20.10_amd64.deb
A couple dependencies were missing so I subsequently ran:
sudo apt --fix-broken install
Just started using it, but MySQL Workbench seems to be running fine. It's also worth mentioning the link below states MySQL Workbench community is not available on Debian, although I'm not sure why this is the case.
mysql-workbench-community - MySQL Workbench (not available for Debian
platforms)
https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/#repo-qg-apt-available
Command line to install mysql on Debian 10:
$ sudo apt update
$ sudo apt upgrade
$ wget http://repo.mysql.com/mysql-apt-config_0.8.13-1_all.deb
$ sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb
Remember to make safe passwords with lettler numbers and symbols
$ sudo apt update
$ sudo apt install mysql-server
$ sudo apt-get build-dep mysql-server
$ wget https://downloads.mysql.com/archives/get/file/mysql-workbench-community_8.0.16-1ubuntu18.04_amd64.deb
$ sudo dpkg -i mysql-workbench-community_8.0.16-1ubuntu18.04_amd64.deb
$ sudo apt install -f
$ sudo dpkg -i mysql-workbench-community_8.0.16-1ubuntu18.04_amd64.deb
have a nice coding!

Error when trying to install app with mysql2 gem

Im trying to install an open source rails 3.2.21 application that uses the mysql2 gem, but when i try and run the bundle commant I get the following error:
Fetching: mysql2-0.3.18.gem (100%)
Building native extensions. This could take a while...
p
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/my_username/.rvm/rubies/ruby-2.1.2/bin/ruby -r ./siteconf20150614-72129-orqsb7.rb extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /usr/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
-----
-----
Setting libpath to /usr/local/Cellar/mysql/5.6.25/lib
-----
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
linking shared-object mysql2/mysql2.bundle
ld: warning: directory not found for option '-L/Users/travis/.sm/pkg/active/lib'
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/my_username/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/mysql2-0.3.18 for inspection.
Results logged to /Users/my_username/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/extensions/x86
I tried uninstalling every version of mysql I installed via homebrew and reinstalling them, like so:
brew uninstall --force mysql && brew install mysql
Then running:
sudo gem install mysql2
As suggested by a number of similar questions asked on here, but it still results in the same error as above.
Please could someone offer guidance on how to get this up and running?
For anybody still experiencing the issue:
When you install openssl via brew, you should get the following message:
Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include
PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
You can set these build flags (for the local application) by running the following:
bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include"
This worked for me.
See bundler's documentation for more information.
The error log says:
ld: library not found for -lssl
So, you need to install libssl:
brew install openssl
As it was pointed out in comments, there might be a need to export the path to the library.
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
Try this:
gem install mysql2 -v '0.5.2' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
(Update version as appropriate)
The solution for me was to install the Xcode Command Line Tools.
I had recently updated Xcode through the Mac App Store, and every time I do that, I've found that I have to reinstall the Command Line Tools again.
xcode-select --install
Based on the solution here
brew install openssl
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
solved the problem.
After Homebrew update (openssl#1.1) there is a new path for libs, so may use:
bundle config build.mysql2 --with-opt-dir=$(brew --prefix openssl)
bundle install
It will fix ld: library not found for -lssl error
Thanks #mudasobwa for pointing me in the right direction. It turns out the error was caused by an unlinked openssl file, so running:
brew reinstall openssl && brew link openssl --force
Solved the problem. I found the solution here: OpenSSL, RVM, Brew, conflicting error
On MacBook air M1(macOS) it worked for me.
Install zstd
brew install zstd
Install mysql2
gem install mysql2 -v '0.5.3' -- --with-opt-dir=$(brew --prefix openssl) --with-ldflags=-L/opt/homebrew/Cellar/zstd/1.5.0/lib
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
From here:
https://gorails.com/setup/osx/10.14-mojave
The combination of commands solved it me. I am on Mojave.
brew reinstall openssl && brew link openssl --force
and then
gem install mysql2 -v '0.4.10' -- \
--with-ldflags=-L/usr/local/opt/openssl/lib \
--with-cppflags=-I/usr/local/opt/openssl/include
Steps for me on Monterey M1 Mac
brew install openssl#3
brew install zstd
gem install mysql2 -v '0.5.3' -- --with-opt-dir=$(brew --prefix openssl) --with-ldflags=-L/opt/homebrew/Cellar/zstd/1.5.0/lib
bundle config --local build.mysql2 "--with-opt-dir=$(brew --prefix openssl) --with-ldflags=-L/opt/homebrew/Cellar/zstd/1.5.0/lib"
bundle install
Seems that you miss the main files needed to build mysql2 gem
sudo apt-get install libsqlite3-dev libmysqlclient-dev -y
libsqlite3-dev is not mandatory but install it since it's the default rails DB.
Mac Catalina using Homebrew fix:
gem install mysql2 -- --with-opt-dir="$(brew --prefix openssl)"
the following command works for my Mac os 12.1 MacOs Monterey
gem install mysql2 -v '0.5.3' -- \
--with-mysql-lib=/opt/homebrew/Cellar/mysql/8.0.28/lib \
--with-mysql-dir=/opt/homebrew/Cellar/mysql/8.0.28 \
--with-mysql-config=/opt/homebrew/Cellar/mysql/8.0.28/bin/mysql_config \
--with-mysql-include=/opt/homebrew/Cellar/mysql/8.0.28/include
Please refer this link for more details
https://github.com/brianmario/mysql2/issues/1175
This finally worked for me on macOS Monterey 12.3 (M1 Pro):
gem install mysql2 -- --with-mysql-dir=/opt/homebrew/Cellar/mysql/8.0.28_1
Make sure you read the installation instructions. Notable points for me were:
Make sure MySQL is installed (brew install mysql)
Make sure XCode select tools are installed (xcode-select --install)
Set the with-mysql-dir option to wherever mysql was installed (check with brew info mysql)
Combining the answers given by Aleksei Matiushkin and Alexey Mozorov fixed the problem for me.
But I also updated the openssl before adding the path.
Thanks!
I've been coding with mysql2 gem for years and have encountered with this issue time to time.
Today I found that this magic option -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include no longer worked on my Mac. Indeed, it looks like the default location where brew installs openssl has changed:
$ brew reinstall openssl
...
If you need to have openssl#3 first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/openssl#3/bin:$PATH"' >> ~/.zshrc
For compilers to find openssl#3 you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/openssl#3/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl#3/include"
So following the message, I had to make a few changes to the command and got it work finally:
$ gem install mysql2 -v '0.5.3' -- --with-ldflags=-L/opt/homebrew/opt/openssl#3/lib --with-cppflags=-I/opt/homebrew/opt/openssl#3/include
Hope this will help someone!
This helped me on MacOs 12.6 (Monterey)
brew install mysql openssl
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
gem install mysql2 -v '0.5.3' \
--source 'https://rubygems.org/' -- \
--with-cppflags=-I/usr/local/opt/openssl/include \
--with-ldflags=-L/usr/local/opt/openssl/lib
bundle install
Thanks https://github.com/brianmario/mysql2/issues/1175#issuecomment-1069721834
I found that I had to use --with-opt-dir=/usr/local/opt.
Specifically, I added the following to my ~/.bundle/config file:
BUNDLE_BUILD__MYSQL2: "--with-opt-dir=/usr/local/opt"

Trouble reinstalling mysql on OSX Mavericks

I'm trying to reinstall mysql on my computer (os x mavericks) and I've done the following with the following errors:
bash <(curl -Ls http://git.io/eUx7rg)
Error:
Starting MySQL
... ERROR! The server quit without updating PID file (/usr/local/mysql/data/christians-mbp.saumag.edu.pid).
/usr/local/mysql/support-files/mysql.server: line 362: pidof: command not found
/dev/fd/63: line 119: SORRY, MySQL IS NOT RUNNING ... THERE MUST BE A PROBLEM: command not found
So I decided to see uninstall it if it was already there:
brew uninstall mysql
bash <(curl -Ls http://git.io/eUx7rg)
This says that mysql is currently still installed, so I did the following:
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*
bash<(curl -Ls http://git.io/eUx7rg)
This gave me the same error messages as before, So I decided to redo all the rm commands above, including the edit and run the following commands:
ps -ax | grep mysql
brew cleanup
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
brew doctor
brew update
brew install mysql
unset TMPDIR
mysql_install_db --verbose --user=`yyttr3` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
After the last command I got the following error message:
dyld: Library not loaded: ##HOMEBREW_PREFIX##/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /usr/local/opt/mysql/bin/my_print_defaults
Reason: image not found
FATAL ERROR: Neither host 'christians-mbp.saumag.edu' nor 'localhost' could be looked up with
/usr/local/opt/mysql/bin/resolveip
Please configure the 'hostname' command to return a correct
hostname.
If you want to solve this at a later stage, restart this script
with the --force option
I don't really know what the problem is, i'm not sure if i'm even installing it right. From what I have read this should be a good way to install mysql. If you have any ideas on what I would greatly appreciate it.
I'm sure you've solved this by now, but I just had the same problem. For anyone else who stumbles across this:
For me, it was an issue with OpenSSL.
resolveip `hostname`
If it says OpenSSL isn't loaded,
brew uninstall openssl
brew install openssl
then try again. Hope this helps.
I had the same problem. Only solution that I found is to install mysql from source code. The reason for this error to occur and how to solve it is explained in full detail in the following link: http://jaitechwriteups.blogspot.com.au/2010/08/mysql-installation-error-neither-host.html
All I had to do was agree XCODE terms by opening XCODE. That fixed everything.

Snow Leopard + Ruby 1.9.1 + MySQL Gem = Huge problems

I tried for about 3-4 hours trying to get the mysql gem to install for ruby 1.9.1 on snow leopard. The mysql gem used to work just fine on 1.9.1 before I upgraded to snow leopard. I uninstalled MySQL server and gem from my machine. I then downloaded and installed: mysql-5.1.37-osx10.5-x86_64.dmg. I have been able to assert that this new version I installed is running as a 64bit application.
I uninstalled the mysql gem. When I tried to install the gem with this command:
env ARCHFLAGS="-arch x86_64" gem install mysql --verbose -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
I got this error:
GET 304 Not Modified: http://gems.rubyforge.org/latest_specs.4.8.gz
GET 200 OK: http://gems.github.com/latest_specs.4.8.gz
Installing gem mysql-2.8.1
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/COPYING
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/COPYING.ja
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/History.txt
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/Manifest.txt
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/README.txt
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/Rakefile
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/ext/mysql_api/extconf.rb
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/ext/mysql_api/mysql.c
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/extra/README.html
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/extra/README_ja.html
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/extra/tommy.css
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/lib/mysql.rb
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/tasks/gem.rake
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/tasks/native.rake
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/tasks/vendor_mysql.rake
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/test/test_mysql.rb
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/Users/sean/.rvm/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/sean/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/i386-darwin9.8.0 -I/Users/sean/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/backward -I/Users/sean/.rvm/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 -g -Os -arch x86_64 -fno-common -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/sean/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby.h:32,
from mysql.c:5:
/Users/sean/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/ruby.h: In function 'INT2NUM':
/Users/sean/.rvm/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/sean/.rvm/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/sean/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/ruby.h: In function 'UINT2NUM':
/Users/sean/.rvm/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/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1 for inspection.
Results logged to /Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
I have tried everything I have read from the following links.
http://void-design.net/2009/08/05/ruby-191-mysql-and-a-snow-leopard/
http://www.schmidp.com/2009/06/14/rubyrails-and-mysql-on-snow-leopard-10a380/
Rails, MySQL and Snow Leopard
Any ideas?
Sean, I see that you are running Ruby 1.9.1 under rvm. I'm having the same problem under the same setup (Snow Leopard, rvm, MySQL 64-bit package). All of the alternate gems (mysqlplus, kwatch-mysql-ruby, etc) fail with the same error.
I would suspect the MySQL install, but everything works like a champ under the system default Ruby. So I wonder if rvm isn't the monkey wrench somehow.
EDIT: I figured it out. I installed rvm before upgrading to Snow Leopard, so my Ruby 1.9.1 install needed to be recompiled. For good measure, I reinstalled rvm from scratch.
Here's what I did:
sudo gem uninstall rvm
rm -rf ~/.gem
sudo gem install rvm
rvm-install
rvm install 1.9.1
rvm 1.9.1
env ARCHFLAGS="-arch x86_64" gem install mysql
(NOTE: You cannot use sudo when installing gems under rvm, because rvm works by modifying $PATH.)
(NOTE: I added /usr/local/mysql/bin to my $PATH so I didn't have to specify any of those awful command-line args when installing the mysql gem.)
The mysql gem installed without a hitch.
I solved this problem by installing MySQL from MacPorts and then running the same gem install command that you have up there.
So, first, uninstall the MySQL you have from the package:
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
If you haven't done it yet, install MacPorts from here: http://www.macports.org/install.php
There's a package for Snow Leopard.
Install mysql5-devel from MacPorts:
sudo port install mysql5-server-devel
It'll do all the dependencies and then MySQL. Follow all the post-install steps that the installer recommends - start-up items, etc. The MySQL it installs is 64-bit.
Then install the MySQL gem with:
env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/opt/local/bin/mysql_config5
Note the path changes there. MacPorts puts MySQL in different places.
You should be good to go.
I tried all the above steps with no luck, but discovered a workaround (or whatever) using the mysqlplus gem instead of the mysql gem:
sudo env ARCHFLAGS="-arch x86_64" gem install mysqlplus
And now my MySQL ruby apps work like a charm in Snow Leopard.
Installing XCode was the solution for me
Take a look at this post: http://jameseggers.com/post/185690322/fix-mysql-and-rails-on-snow-leopard . It shows how to get MySQL + Ruby on Rails + Snow Leopard all working perfectly.
Found a great tutorial online for this.
http://www.icoretech.org/2009/08/install-mysql-and-mysql-ruby-gem-on-snow-leopard-64-bit/
Setting the PATH variable was my problem.
I had the same problem with mysql gem, rvm and ruby 1.9.1. As mentioned in my post at NeptunePhoenix, I had success by installing mysql via port.
Struggled for hours before stumbling on this:
http://markgandolfo.com/2010/08/21/mysql-gem-with-rails-3-and-ruby-1-9-2
The fix with me was re-installing MySQL. I used the 64bit DMG installation version - 5.5.13
http://dev.mysql.com/downloads/mysql/