我对rails非常陌生,并且正在尝试通过Lynda.com上的 Rails Essential Training 来熟悉该框架。虽然我认为我已正确安装了所有内容,但在尝试启动WEBrick服务器时遇到了一些麻烦。这个问题似乎与mySQL有关,因为我在退出后就出错了,我不知道它试图告诉我什么。如果有人可以看看错误并推荐任何可能的解决方案,将非常感谢!!
我正在跑步:
OSX Mountain Lion
Ruby 2.0
Rails 3.2.13
mysql Ver 14.14 Distrib 5.6.10,for osx10.8
adamcord$ rails s
=> Booting WEBrick
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect': Unknown database 'simple_cms_development' (Mysql2::Error)
from /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `initialize'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `send'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `checkout'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `checkout'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `connection'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/railtie.rb:88
from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `run_initializers'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `send'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/adamcord/Desktop/Course Work/Lynda.com Exercises/Sites/simple_cms/config/environment.rb:5
from /Users/adamcord/Desktop/Course Work/Lynda.com Exercises/Sites/simple_cms/config.ru:3:in `require'
from /Users/adamcord/Desktop/Course Work/Lynda.com Exercises/Sites/simple_cms/config.ru:3
from /Library/Ruby/Gems/1.8/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /Library/Ruby/Gems/1.8/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from /Users/adamcord/Desktop/Course Work/Lynda.com Exercises/Sites/simple_cms/config.ru:0:in `new'
from /Users/adamcord/Desktop/Course Work/Lynda.com Exercises/Sites/simple_cms/config.ru:0
我尝试过使用rake db:create
命令,但这似乎打开了一大堆问题。
答案 0 :(得分:0)
您尝试连接的数据库不存在:
未知数据库'simple_cms_development'
您可以检查它是否确实存在,以及您的config / database.yml中的设置是否正确?这也可能是rake db:create也失败的原因(粘贴你从中获得的错误会很有用)。