gpt4 book ai didi

mysql - 无法连接到 '127.0.0.1' 上的 MySQL 服务器

转载 作者:行者123 更新时间:2023-11-29 06:32:06 25 4
gpt4 key购买 nike

我刚刚为 Windows 8 安装了 mysql2 gem,但安装过程非常困难。安装后,我仍然无法运行我的 Rails 应用程序。

系统信息

  • 操作系统:Windows 8
  • Ruby 版本:2.0.0p481 (2014-05-08) [i386-mingw32]

gem 文件

gem 'mysql2', '0.3.17'

数据库.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

我花了几个小时尝试安装 gem,然后又花了几个小时解决了这个问题。我不知道问题出在哪里,但我需要解决这个问题。

提前感谢您的帮助。

最佳答案

Can't connect to MySQL server on '127.0.0.1' 错误通常表示您的 MySQL 服务未运行。您确定已将应用程序指向数据库服务的正确主机和端口吗?

关于mysql - 无法连接到 '127.0.0.1' 上的 MySQL 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27283714/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com