简体   繁体   English

Rails服务器将无法运行-这是mysql2问题吗?

[英]Rails server will not run - is this a mysql2 problem?

Following a tutorial PRECISELY and trying to get rails server to run and getting the following error: 严格按照教程进行操作,尝试使Rails服务器运行并出现以下错误:

NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
    Gem.source_index called from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/shared_helpers.rb:3.
    NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
    Gem.source_index called from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/source.rb:162.
    NOTE: Gem::SourceIndex#each is deprecated with no replacement. It will be removed on or after 2011-11-01.
    Gem::SourceIndex#each called from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/source.rb:162.
    NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
    Gem.source_index called from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/shared_helpers.rb:84.
    /Library/Ruby/Gems/1.8/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
      Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle
      Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle
        from /Library/Ruby/Gems/1.8/gems/mysql2-0.2.11/lib/mysql2.rb:9
        from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
        from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
        from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'
        from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `require'
        from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'
        from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'
        from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'
        from /Users/EricFriedman/Sites/simple_cms/config/application.rb:7
        from /Library/Ruby/Gems/1.8/gems/railties-3.0.8/lib/rails/commands.rb:28:in `require'
        from /Library/Ruby/Gems/1.8/gems/railties-3.0.8/lib/rails/commands.rb:28
        from /Library/Ruby/Gems/1.8/gems/railties-3.0.8/lib/rails/commands.rb:27:in `tap'
        from /Library/Ruby/Gems/1.8/gems/railties-3.0.8/lib/rails/commands.rb:27
        from script/rails:6:in `require'
        from script/rails:6

You need to lock down your version of mysql2 if you are using Rails 3.0.x. 如果您使用的是Rails 3.0.x,则需要锁定mysql2的版本。 In your Gemfile: 在您的Gemfile中:

gem "mysql2", "~> 0.2.11"

Then run bundle install or bundle update mysql2 . 然后运行bundle installbundle update mysql2

Edit : 编辑

I notice you are using the 0.2.11 version of the mysql2 gem. 我注意到您正在使用mysql2 gem的0.2.11版本。

Looking more closely, I noticed this error: 仔细观察,我发现此错误:

Library not loaded: libmysqlclient.18.dylib (LoadError) 库未加载:libmysqlclient.18.dylib(LoadError)

This may indicate that the mysql development headers/libraries are not available. 这可能表明mysql开发标头/库不可用。 Your installation the mysql2 gem should have failed when you ran bundle install . 当您运行bundle install时,安装mysql2 gem应该失败。 If so, you need to install these development libraries and then reinstall the gem. 如果是这样,则需要安装这些开发库,然后重新安装gem。

Library not loaded: libmysqlclient.18.dylib (LoadError)

you need mysql install on your box. 您需要在盒子上安装mysql。

if you type mysql into a terminal what happens? 如果将mysql输入终端,会发生什么?

also

if you type mysql --version into a terminal what happens? 如果您将mysql --version输入终端,会发生什么?

This worked for me: 这为我工作:

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib 须藤ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

Here is the original post: http://c.kat.pe/post/how-to-fix-mysql-load-issues-on-mac-os-x/ 这是原始帖子: http : //c.kat.pe/post/how-to-fix-mysql-load-issues-on-mac-os-x/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM