Mac上的Rails - rake db:创建错误

时间:2014-01-04 17:30:02

标签: mysql ruby-on-rails ruby macos

我在我的MAC(Mavericks 10.9.1)上安装了RVM和rails,我尝试运行rake db:create。但是我经常遇到这个错误:

 MacBook-Pro-Szymon:wybierzto Fengson$ rake db:create
    rake aborted!
    dlopen(/Users/Fengson/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/extensions/x86_64-darwin-12/2.0.0-static/mysql2-0.3.14/mysql2/mysql2.bundle, 9): Library not loaded: /opt/local/lib/mysql5/mysql/libmysqlclient_r.16.dylib
      Referenced from: /Users/Fengson/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/extensions/x86_64-darwin-12/2.0.0-static/mysql2-0.3.14/mysql2/mysql2.bundle
      Reason: image not found - /Users/Fengson/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/extensions/x86_64-darwin-12/2.0.0-static/mysql2-0.3.14/mysql2/mysql2.bundle
    /Users/Fengson/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/mysql2-0.3.14/lib/mysql2.rb:8:in `require'
    /Users/Fengson/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/mysql2-0.3.14/lib/mysql2.rb:8:in `<top (required)>'
    /Users/Fengson/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/runtime.rb:76:in `require'
    /Users/Fengson/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    /Users/Fengson/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/runtime.rb:72:in `each'
    /Users/Fengson/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/runtime.rb:72:in `block in require'
    /Users/Fengson/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/runtime.rb:61:in `each'
    /Users/Fengson/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/runtime.rb:61:in `require'
    /Users/Fengson/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler.rb:131:in `require'
    /Users/Fengson/UJ/ProjektZespolowy/wybierzto/config/application.rb:12:in `<top (required)>'
    /Users/Fengson/UJ/ProjektZespolowy/wybierzto/Rakefile:4:in `require'
    /Users/Fengson/UJ/ProjektZespolowy/wybierzto/Rakefile:4:in `<top (required)>'
    /Users/Fengson/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in `eval'
    /Users/Fengson/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in `<main>'
    (See full trace by running task with --trace)

另外,如何才能正确安装MySQL Server以便设置默认密码?它问我在Windows机器上输入密码,但是在我安装MySQL5 + server时没有。谢谢!

1 个答案:

答案 0 :(得分:1)

尝试通过自制程序重新安装mysql。并重新安装mysql gem
 gem install mysql -- --with-mysql-config path/to/mysql_config