■MySQLのインストール
ダウンロードページ(執筆時の最新版5.0)から
Mac OS X 10.5 (x86_64)をダウンロード。
ダウンロードしたファイルの手順に従ってインストール。
■データベースの作成
まずはエイリアスを作成。これでmysql hogehoge mysqlamdmin hoge hogeでデータベース作成などのコマンドが可能。
alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin
■sudo gem install mysql できない><
ターミナルのエラー内容
sudo gem install mysql
Bulk updating Gem source index for: http://gems.rubyforge.org
Select which gem to install for your platform (i686-darwin8.9.1)
1. mysql 2.7.3 (mswin32)
2. mysql 2.7.1 (mswin32)
3. mysql 2.7 (ruby)
4. mysql 2.6 (ruby)
5. Skip this gem
6. Cancel installation
> 3
Building native extensions. This could take a while...
ERROR: While executing gem ... (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.
ruby extconf.rb install mysql
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=/opt/local/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
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
参考:MacのLepoardでsudo gem install hogehogeができない件
■Xcodeのインストール
Appleからダウンロードも可能ですが、登録が必要なのでLeopardのンストールディスクからインストール。
1枚目にあるかと思いきや、2枚目に入っていました><
(MB402J/Aの場合)
■もう一回gem install mysql
ダメです><
どうやらオプションが必要なようで、
sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
参考:Rails gem install mysql throws error: *** extconf.rb failed ***
■rake db:migrate で問題発生
rake db:migrate
(in /Users/User/Projects/)
dyld: lazy symbol binding failed: Symbol not found: _mysql_init
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle
Expected in: dynamic lookupdyld: Symbol not found: _mysql_init
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle
Expected in: dynamic lookup
Trace/BPT trap
Issues with mysql 2.7 gem
なにこの既視感><
どうやらこのMichaelと同じ道を辿ってきたみたい><
これもまた、オプションを指定するらしい。
なにをしているかはさっぱり><
sudo env ARCHFLAGS="-arch x86_64" gem install mysql --
$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Password:
Building native extensions. This could take a while...
Successfully installed mysql-2.7
1 gem installed
