简体   繁体   English

未初始化常量 Mysql::error

[英]uninitialized constant Mysql::error

I am trying to get my rails app to production but this is my first time.我正在尝试将我的 rails 应用程序投入生产,但这是我的第一次。 I am running mysql 5.5 and gem 2.8.1.我正在运行 mysql 5.5 和 gem 2.8.1。

When trying rake db:setup RAILS_ENV="production", I get the following:尝试 rake db:setup RAILS_ENV="production" 时,我得到以下信息:

rake aborted!
uninitialized constant Mysql::Error

any help is much appreciated任何帮助深表感谢

i thought it might be useful to add the trace file for this error.我认为为这个错误添加跟踪文件可能很有用。 any help would be greatly appreciated:任何帮助将不胜感激:

rake db:setup RAILS_ENV="production" --trace
(in /Users/chris/rails_projects/sienab)
** Invoke db:setup (first_time)
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:create
rake aborted!
uninitialized constant Mysql::Error
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.6/lib/active_record/railties/databases.rake:64:in `create_database'
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.6/lib/active_record/railties/databases.rake:35
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

As mentioned in Rails 3 Mysql Problems you should be using the mysql2 gem if possible.正如Rails 3 Mysql 中提到的问题,如果可能,您应该使用mysql2 gem。

Make sure to change mysql to mysql2 in both your Gemfile and your database.yml确保在 Gemfile 和 database.yml 中将mysql更改为mysql2

The actual error is about Mysql::Error constant.实际错误大约是 Mysql::Error 常量。

Are you including mysql gem in Gemfile?您是否在 Gemfile 中包含 mysql gem?

Are you using mysql in database.yml?您在 database.yml 中使用 mysql 吗?

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

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