0

嘿,我不知道该怎么做才能修复此错误消息。刚开始使用带有 Rails 的 ruby​​ 并尝试将其全部设置好,以便我可以了解更多信息,但并坚持尝试让 WEBrick 工作。任何事情都会有所帮助,谢谢!

 C:\Users\Brandon\Documents\Sites\simple_cms>rails server
=> 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
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connec
tion_adapters/mysql_adapter.rb:411:in `real_connect': Can't connect to MySQL ser
ver on 'localhost' (10061) (Mysql::Error)
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_
record/connection_adapters/mysql_adapter.rb:411:in `connect'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_
record/connection_adapters/mysql_adapter.rb:131:in `initialize'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_
record/connection_adapters/mysql_adapter.rb:38:in `new'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_
record/connection_adapters/mysql_adapter.rb:38:in `mysql_connection'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_ 
record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_
record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_conn
ection'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_
record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels)
in checkout'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_
record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_
record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout
'
    from C:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_ 
record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_
record/connection_adapters/abstract/connection_pool.rb:102:in `block in connecti
on'
    from C:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_
record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_
record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connecti   
on'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_
record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve
_connection'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_
record/connection_adapters/abstract/connection_specification.rb:145:in `connecti
on'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_
record/railtie.rb:88:in `block in <class:Railtie>'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/initi
alizable.rb:30:in `instance_exec'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/initi
alizable.rb:30:in `run'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/initi
alizable.rb:55:in `block in run_initializers'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/initi
alizable.rb:54:in `each'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/initi
alizable.rb:54:in `run_initializers'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/appli
cation.rb:136:in `initialize!'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/railt
ie/configurable.rb:30:in `method_missing'
    from C:/Users/Brandon/Documents/Sites/simple_cms/config/environment.rb:5
:in `<top (required)>'
    from C:/Users/Brandon/Documents/Sites/simple_cms/config.ru:3:in `require
'
    from C:/Users/Brandon/Documents/Sites/simple_cms/config.ru:3:in `block i
n <main>'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:
51:in `instance_eval'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:
51:in `initialize'
    from C:/Users/Brandon/Documents/Sites/simple_cms/config.ru:in `new'
    from C:/Users/Brandon/Documents/Sites/simple_cms/config.ru:in `<main>'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:
40:in `eval'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:
40:in `parse_file'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:2
00:in `app'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/comma
nds/server.rb:46:in `app'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:3
04:in `wrapped_app'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:2
54:in `start'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/comma
nds/server.rb:70:in `start'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/comma
nds.rb:55:in `block in <top (required)>'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/comma
nds.rb:50:in `tap'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/comma
nds.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

我正在尝试一些不同的事情来完成这项工作,我看到有人说这可能是没有 gemfile opensll 或其他东西的问题,然后我读了另一件事,上面写着要尝试 rake db:create,我也收到了这个错误消息.

C:\Users\Brandon\Documents\Sites\simple_cms>rake db:create
Can't connect to MySQL server on 'localhost' (10061)
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "reconnec
t"=>false, "database"=>"simple_cms_development", "pool"=>5, "username"=>"root",
"password"=>nil, "host"=>"localhost"}, charset: utf8, collation: utf8_unicode_ci

(if you set the charset manually, make sure you have a matching collation)
Can't connect to MySQL server on 'localhost' (10061)
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "reconnec
t"=>false, "database"=>"simple_cms_test", "pool"=>5, "username"=>"root", "passwo
rd"=>nil, "host"=>"localhost"}, charset: utf8, collation: utf8_unicode_ci
(if you set the charset manually, make sure you have a matching collation)
4

2 回答 2

0

您需要在此处为​​ Windows 安装 mysql 。Mysql 不是 Ruby 环境的一部分,它不被 Bundler 和/或 Rails 处理。您的计算机上是否安装了 mysql 实例?

于 2013-04-18T04:07:10.253 回答
0

看起来任何配置信息config/database.yml都无效,或者您没有正确配置 MySQL 服务器。

从您收到的错误来看,您的 MySQL 服务器似乎没有运行,或者没有在您定义的端口上响应。

测试您是否可以使用mysql命令行工具或等效工具进行连接。

于 2013-04-18T01:51:49.293 回答