gem install mysql でエラーになる件

rake db:createとしようとすると、下記のようなエラーメッセージ。


!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!
no such file to load -- mysql


言われるがまま、gem install mysqlとすると、


WARNING: Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
/usr/bin aren't both writable.
WARNING: You don't have /Users/BillEvans/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
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

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.


とエラーに。


結論から言うと、下のコマンドで無事インストール完了。
自分向けのメモとして。


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