简体   繁体   中英

Error running WEBrick: Can't Connect to MySQL server

Hey I can't figure out what to do to fix this error message. Just started with ruby with rails and trying to get it all set up so I can learn more but and stuck on trying to get WEBrick to work. Anything will help, THANKS!

 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>'

I am trying some different things to make this work and I seen someone said it could be a problem with not having a gemfile opensll or something and then I read another thing where it said to try rake db:create and I got this error message also.

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)

It looks like whatever configuration information in config/database.yml is invalid or you haven't configured your MySQL server correctly.

From the error you're receiving it looks like your MySQL server isn't running, or isn't responding on the port you've defined.

Test that you can connect with the mysql command-line tool or something equivalent.

You need to install mysql for Windows Here . Mysql is a not part of the Ruby environment and it is not handled with Bundler and/or Rails. Do you have an instance of mysql installed on your computer?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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