我刚为mysql2
安装了Windows 8
宝石,并且非常困难。安装后,我仍然无法运行我的Rails应用程序。
系统信息
的Gemfile
gem 'mysql2', '0.3.17'
的database.yml
development:
adapter: mysql2
encoding: utf8
database: db_development
pool: 5
username: root
password:
socket: /var/run/mysqld/mysqld.sock
host: 127.0.0.1
port: 3306
我在开发日志中获得此输出
DL is deprecated, please use Fiddle
=> Booting WEBrick
=> Rails 4.0.2 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2014-12-03 17:33:49] INFO WEBrick 1.3.1
[2014-12-03 17:33:49] INFO ruby 2.0.0 (2014-05-08) [i386-mingw32]
[2014-12-03 17:33:49] INFO WEBrick::HTTPServer#start: pid=53748 port=3000
Started GET "/" for 127.0.0.1 at 2014-12-03 17:34:07 -0600
Mysql2::Error (Can't connect to MySQL server on '127.0.0.1' (10061)):
mysql2 (0.3.17) lib/mysql2/client.rb:70:in `connect'
mysql2 (0.3.17) lib/mysql2/client.rb:70:in `initialize'
activerecord (4.0.2) lib/active_record/connection_adapters/mysql2_adapter.rb:1
8:in `new'
activerecord (4.0.2) lib/active_record/connection_adapters/mysql2_adapter.rb:1
8:in `mysql2_connection'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection
_pool.rb:440:in `new_connection'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection
_pool.rb:450:in `checkout_new_connection'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection
_pool.rb:421:in `acquire_connection'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection
_pool.rb:356:in `block in checkout'
C:/Ruby200/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection
_pool.rb:355:in `checkout'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection
_pool.rb:265:in `block in connection'
C:/Ruby200/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection
_pool.rb:264:in `connection'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection
_pool.rb:546:in `retrieve_connection'
activerecord (4.0.2) lib/active_record/connection_handling.rb:79:in `retrieve_
connection'
activerecord (4.0.2) lib/active_record/connection_handling.rb:53:in `connectio
n'
activerecord (4.0.2) lib/active_record/migration.rb:792:in `current_version'
activerecord (4.0.2) lib/active_record/migration.rb:800:in `needs_migration?'
activerecord (4.0.2) lib/active_record/migration.rb:379:in `check_pending!'
activerecord (4.0.2) lib/active_record/migration.rb:366:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/callbacks.rb:29:in `block in
call'
activesupport (4.0.2) lib/active_support/callbacks.rb:373:in `_run__768443287_
_call__callbacks'
activesupport (4.0.2) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/reloader.rb:64:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `c
all'
actionpack (4.0.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `ca
ll'
railties (4.0.2) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.2) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `block in tag
ged'
activesupport (4.0.2) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.2) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.0.2) lib/active_support/cache/strategy/local_cache.rb:83:in `
call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.0.2) lib/rails/engine.rb:511:in `call'
railties (4.0.2) lib/rails/application.rb:97:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
C:/Ruby200/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
C:/Ruby200/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
C:/Ruby200/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
Rendered C:/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispa
tch/middleware/templates/rescues/_source.erb (1.0ms)
Rendered C:/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispa
tch/middleware/templates/rescues/_trace.erb (3.0ms)
Rendered C:/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispa
tch/middleware/templates/rescues/_request_and_response.erb (3.0ms)
Rendered C:/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispa
tch/middleware/templates/rescues/diagnostics.erb within rescues/layout (101.0ms)
我跑netstat -a
来测试我的连接
netstat -a
Active Connections
Proto Local Address Foreign Address State
TCP 0.0.0.0:135 rh-pc:0 LISTENING
TCP 0.0.0.0:445 rh-pc:0 LISTENING
TCP 0.0.0.0:554 rh-pc:0 LISTENING
TCP 0.0.0.0:2869 rh-pc:0 LISTENING
TCP 0.0.0.0:5357 rh-pc:0 LISTENING
TCP 0.0.0.0:6646 rh-pc:0 LISTENING
TCP 0.0.0.0:8732 rh-pc:0 LISTENING
TCP 0.0.0.0:10243 rh-pc:0 LISTENING
TCP 0.0.0.0:49152 rh-pc:0 LISTENING
TCP 0.0.0.0:49153 rh-pc:0 LISTENING
TCP 0.0.0.0:49154 rh-pc:0 LISTENING
TCP 0.0.0.0:49155 rh-pc:0 LISTENING
TCP 0.0.0.0:49158 rh-pc:0 LISTENING
TCP 0.0.0.0:49159 rh-pc:0 LISTENING
TCP 127.0.0.1:5354 rh-pc:0 LISTENING
TCP 127.0.0.1:5354 rh-pc:49156 ESTABLISHED
TCP 127.0.0.1:5354 rh-pc:49157 ESTABLISHED
TCP 127.0.0.1:27015 rh-pc:0 LISTENING
TCP 127.0.0.1:27015 rh-pc:64075 ESTABLISHED
TCP 127.0.0.1:49156 rh-pc:5354 ESTABLISHED
TCP 127.0.0.1:49157 rh-pc:5354 ESTABLISHED
TCP 127.0.0.1:63342 rh-pc:63342 ESTABLISHED
TCP 127.0.0.1:64075 rh-pc:27015 ESTABLISHED
TCP 192.168.1.114:139 rh-pc:0 LISTENING
TCP 192.168.1.114:49565 a23-33-171-33:https CLOSE_WAIT
TCP 192.168.1.114:49566 93.184.215.200:http CLOSE_WAIT
TCP 192.168.1.114:49567 a23-33-171-33:https CLOSE_WAIT
TCP 192.168.1.114:49568 a23-33-171-33:https CLOSE_WAIT
TCP 192.168.1.114:49569 a23-33-171-33:https CLOSE_WAIT
TCP 192.168.1.114:49570 a23-33-171-33:https CLOSE_WAIT
TCP 192.168.1.114:49571 a23-33-171-33:https CLOSE_WAIT
TCP 192.168.1.114:49580 a23-33-171-33:https CLOSE_WAIT
TCP 192.168.1.114:49583 a184-50-238-90:http CLOSE_WAIT
TCP 192.168.1.114:49584 a184-50-238-90:http CLOSE_WAIT
TCP 192.168.1.114:49585 a184-50-238-90:http CLOSE_WAIT
TCP 192.168.1.114:49586 a184-50-238-90:http CLOSE_WAIT
TCP 192.168.1.114:49587 a184-50-238-90:http CLOSE_WAIT
TCP 192.168.1.114:49588 a184-50-238-90:http CLOSE_WAIT
TCP 192.168.1.114:49589 a184-50-238-170:http CLOSE_WAIT
TCP 192.168.1.114:49590 a184-50-238-170:http CLOSE_WAIT
TCP 192.168.1.114:49591 a184-50-238-170:http CLOSE_WAIT
TCP 192.168.1.114:49592 a184-50-238-170:http CLOSE_WAIT
TCP 192.168.1.114:49593 a184-50-238-170:http CLOSE_WAIT
TCP 192.168.1.114:49594 a184-50-238-170:http CLOSE_WAIT
TCP 192.168.1.114:51590 stackoverflow:https ESTABLISHED
TCP 192.168.1.114:52160 stackoverflow:https ESTABLISHED
TCP 192.168.1.114:52340 stackoverflow:https ESTABLISHED
TCP 192.168.1.114:53015 stackoverflow:https ESTABLISHED
TCP 192.168.1.114:56954 ord31s21-in-f4:https ESTABLISHED
TCP 192.168.1.114:56992 ord31s21-in-f0:https ESTABLISHED
TCP 192.168.1.114:56993 stackoverflow:https ESTABLISHED
TCP 192.168.1.114:57369 199.16.156.120:https ESTABLISHED
TCP 192.168.1.114:57382 ord08s13-in-f6:https ESTABLISHED
TCP 192.168.1.114:57455 64.233.182.95:https ESTABLISHED
TCP 192.168.1.114:57488 ord08s06-in-f14:https ESTABLISHED
TCP 192.168.1.114:57490 72.21.91.121:https ESTABLISHED
TCP 192.168.1.114:57492 ord08s11-in-f7:http ESTABLISHED
TCP 192.168.1.114:57494 a23-67-60-25:http ESTABLISHED
TCP 192.168.1.114:57495 stackoverflow:https ESTABLISHED
TCP 192.168.1.114:57502 us:http TIME_WAIT
TCP 192.168.1.114:57507 cf-190-93-246-58:http TIME_WAIT
TCP 192.168.1.114:57508 cf-190-93-246-58:http TIME_WAIT
TCP 192.168.1.114:57509 cf-190-93-246-58:http TIME_WAIT
TCP 192.168.1.114:57510 cf-190-93-246-58:http TIME_WAIT
TCP 192.168.1.114:57511 cf-190-93-246-58:http TIME_WAIT
TCP 192.168.1.114:57512 cf-190-93-246-58:http TIME_WAIT
TCP 192.168.1.114:57514 72.5.205.11:http TIME_WAIT
TCP 192.168.1.114:57515 ord08s11-in-f7:http TIME_WAIT
TCP 192.168.1.114:57516 ord08s11-in-f7:http TIME_WAIT
TCP 192.168.1.114:57517 72.21.91.121:https ESTABLISHED
TCP 192.168.1.114:57520 a23-67-60-11:http TIME_WAIT
TCP 192.168.1.114:57521 a23-67-60-11:http TIME_WAIT
TCP 192.168.1.114:57522 103.31.7.32:http CLOSE_WAIT
TCP 192.168.1.114:57523 103.31.7.32:http TIME_WAIT
TCP 192.168.1.114:57524 103.31.7.32:http TIME_WAIT
TCP 192.168.1.114:57525 104.16.12.8:http TIME_WAIT
TCP 192.168.1.114:57526 104.16.12.8:http TIME_WAIT
显示所有活动连接的列表。我在rails s
没有被运行时运行了这个。
这是我的lib/ruby/gems/2.0.0/gems/mysql2-0.3.17
目录
examples (Dir)
ext (Dir)
lib (Dir)
spec (Dir)
support (Dir)
MIT-LICENSE
README.md
这是我的`C:/ Program Files(x86)/ MySQL目录
MySQL Connector C 6.1 (Dir) # Only file in this folder
我花了几个小时试图安装宝石,之后花了几个小时来解决这个问题。我无法弄清楚问题出在哪里,但我需要解决这个问题。
提前感谢您的帮助。
答案 0 :(得分:2)
Can't connect to MySQL server on '127.0.0.1'
的错误通常意味着您的MySQL服务未运行。您确定已将应用程序指向正确的数据库服务主机和端口吗?