启动 Ruby on Rails 服务器时出现问题
我对 Ruby、Rails 和 MySQL 完全陌生。我正在尝试启动一个新项目并启动默认服务器,但收到下面列出的错误。我安装了以下内容:
- Ruby:ruby 1.8.7(2008-08-11 patchlevel 72)[i686-darwin9.8.0]
- Rails:rails(3.0.7)
- MySql:mysql2(0.2.7)
- RubyGems:1.7.2
错误如下:
$ rails s
/usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle: dlsym(0x251680, Init_mysql2): symbol not found - /usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle (LoadError)
from /usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2.rb:8
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler.rb:120:in `require'
from /Users/nelsonwittwer/Sites/simple_cms/config/application.rb:7
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27
from script/rails:6:in `require'
from script/rails:6
我不太确定从这里该去哪里,并且希望您能提供任何帮助。谢谢。
I am completely new to Ruby, Rails, and MySQL. I am trying to start a new project and start the default server and I get the error listed below. I have the following installed:
- Ruby : ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9.8.0]
- Rails: rails (3.0.7)
- MySql: mysql2 (0.2.7)
- RubyGems: 1.7.2
Error is below:
$ rails s
/usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle: dlsym(0x251680, Init_mysql2): symbol not found - /usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle (LoadError)
from /usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2.rb:8
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler.rb:120:in `require'
from /Users/nelsonwittwer/Sites/simple_cms/config/application.rb:7
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27
from script/rails:6:in `require'
from script/rails:6
I'm not quite sure where to go from here and would love any help you may have. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确保您的 ruby 系统中安装了 mysql2 gem。要检查它,请使用gem list -d。如果找不到 mysql2 gem,在 ubuntu 中,您必须在安装 mysql2 gem 之前安装以下库:
之后,您可以使用 sudo gem install mysql2 进行安装,并确保 database.yml 中的适配器值为 mysql2。另一个问题是库未加载,如果问题库未加载:尝试使用 mysql2 gem 在 OS X 10.6 上运行“rails 服务器”时出现 libmysqlclient.16.dylib 错误
make sure you have mysql2 gem installed in your ruby system. To check it use gem list -d. If mysql2 gem not found, in ubuntu you must install following library before install mysql2 gem :
After that, you could install with sudo gem install mysql2 and make sure your adapter value inside database.yml is mysql2. Another issue is Library not loaded, you can view this link if that the problem Library not loaded: libmysqlclient.16.dylib error when trying to run 'rails server' on OS X 10.6 with mysql2 gem
您需要在系统上安装 mySQL gem。
现在,不要使用 apt-get 来安装它,因为 apt-get 通常具有旧版本的 ruby 库。
另外,我强烈建议您在开始时使用 SQLite。
也非常有帮助(在 railstutorial 中进行了描述)
而且,Bundler在基于 ubuntu/debian 的发行版上 (并且您确实想要使用 MySQL):
如果您使用的是 ruby 1.8.x(使用
ruby -v
检查):如果您使用的是 ruby 1.9.x:
You need the mySQL gem installed on your system.
Now, DO NOT use apt-get to install this, as apt-get often has old versions of the ruby libraries.
Also, I would highly recommend you use SQLite when starting out.
And, Bundler is also very helpful (described in the railstutorial)
On ubuntu/debian based distributions (and you really want to use MySQL):
If you are using ruby 1.8.x (check with
ruby -v
):If you are using ruby 1.9.x: