Info

前回の続き 「Mac ( Snow Leopard ) に RubyOnRails3 環境構築」でMySQL編です。

1. MySQLインストール
Mac OS X に MySQL をインストール

2. database.xml

development:
  adapter: mysql2
  database: railsdev
  host: localhost
  username: dongrikim
  password: test
  encoding: utf8

3. Gemfile

gem 'mysql2'

4. bundle install

$ bundle install

5. libmysqlclient.18.dylib

$ sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /opt/local/lib/ruby1.9/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle

rvm 使ってた場合:

$ sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /Users/dongri/.rvm/gems/ruby-1.9.3-p374/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle 

以上で、設定完了。

エラー編:
1. エラーその1

Gem files will remain installed in /Users/dongrikim/.bundler/tmp/98945/gems/mysql2-0.2.6 for inspection.
Results logged to /Users/dongrikim/.bundler/tmp/98945/gems/mysql2-0.2.6/ext/mysql2/gem_make.out
	from /opt/local/lib/ruby1.9/1.9.1/rubygems/installer.rb:486:in `block in build_extensions'
	from /opt/local/lib/ruby1.9/1.9.1/rubygems/installer.rb:446:in `each'
	from /opt/local/lib/ruby1.9/1.9.1/rubygems/installer.rb:446:in `build_extensions'
	from /opt/local/lib/ruby1.9/1.9.1/rubygems/installer.rb:198:in `install'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/source.rb:96:in `install'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/installer.rb:55:in `block in run'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/spec_set.rb:12:in `block in each'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/spec_set.rb:12:in `each'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/spec_set.rb:12:in `each'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/installer.rb:44:in `run'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/installer.rb:8:in `install'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/cli.rb:225:in `install'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/vendor/thor/task.rb:22:in `run'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/vendor/thor.rb:246:in `dispatch'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/vendor/thor/base.rb:389:in `start'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.12/bin/bundle:13:in `'
	from /opt/local/bin/bundle:19:in `load'
	from /opt/local/bin/bundle:19:in `'

解決方法「1. MySQLインストール」 を行う。

2. エラーその2

/opt/local/lib/ruby1.9/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2.rb:7:in `require': dlopen(/opt/local/lib/ruby1.9/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
  Referenced from: /opt/local/lib/ruby1.9/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
  Reason: image not found - /opt/local/lib/ruby1.9/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2.rb:7:in `'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `block in require'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.12/lib/bundler.rb:120:in `require'
	from /Users/dongrikim/Dropbox/Developer/Rails/dislike/config/application.rb:7:in `'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:28:in `require'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:28:in `block in '
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:27:in `tap'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:27:in `'
	from script/rails:6:in `require'
	from script/rails:6:in `'

解決方法「5. libmysqlclient.18.dylib」を行う。

Advertisements

Comments

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Basic HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS