0

我有一个奇怪的问题。当我尝试 ro makerails s时,它​​说我:

C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/conne
ction_adapters/mysql_adapter.rb:411:in `real_connect': Can't connect to MySQL se
rver on '127.0.0.0' (10060) (Mysql::Error)
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active
_record/connection_adapters/mysql_adapter.rb:411:in `connect'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active
_record/connection_adapters/mysql_adapter.rb:131:in `initialize'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active
_record/connection_adapters/mysql_adapter.rb:38:in `new'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active
_record/connection_adapters/mysql_adapter.rb:38:in `mysql_connection'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active
_record/connection_adapters/abstract/connection_pool.rb:309:in `new_connection'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active
_record/connection_adapters/abstract/connection_pool.rb:319:in `checkout_new_con
nection'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active
_record/connection_adapters/abstract/connection_pool.rb:241:in `block (2 levels)
 in checkout'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active
_record/connection_adapters/abstract/connection_pool.rb:236:in `loop'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active
_record/connection_adapters/abstract/connection_pool.rb:236:in `block in checkou
t'
        from C:/Ruby/ruby/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active
_record/connection_adapters/abstract/connection_pool.rb:233:in `checkout'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active
_record/connection_adapters/abstract/connection_pool.rb:96:in `block in connecti
on'
        from C:/Ruby/ruby/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active
_record/connection_adapters/abstract/connection_pool.rb:95:in `connection'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active
_record/connection_adapters/abstract/connection_pool.rb:404:in `retrieve_connect
ion'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active
_record/connection_adapters/abstract/connection_specification.rb:170:in `retriev
e_connection'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active
_record/connection_adapters/abstract/connection_specification.rb:144:in `connect
ion'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active
_record/model_schema.rb:308:in `clear_cache!'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active
_record/railtie.rb:97:in `block (2 levels) in <class:Railtie>'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/activ
e_support/callbacks.rb:418:in `_run__319095901__prepare__837475246__callbacks'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/activ
e_support/callbacks.rb:405:in `__run_callback'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/activ
e_support/callbacks.rb:385:in `_run_prepare_callbacks'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/activ
e_support/callbacks.rb:81:in `run_callbacks'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_d
ispatch/middleware/reloader.rb:74:in `prepare!'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_d
ispatch/middleware/reloader.rb:48:in `prepare!'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/appl
ication/finisher.rb:47:in `block in <module:Finisher>'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/init
ializable.rb:30:in `instance_exec'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/init
ializable.rb:30:in `run'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/init
ializable.rb:55:in `block in run_initializers'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/init
ializable.rb:54:in `each'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/init
ializable.rb:54:in `run_initializers'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/appl
ication.rb:136:in `initialize!'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/rail
tie/configurable.rb:30:in `method_missing'
        from C:/Ruby/acturevue/config/environment.rb:5:in `<top (required)>'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/activ
e_support/dependencies.rb:251:in `require'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/activ
e_support/dependencies.rb:251:in `block in require'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/activ
e_support/dependencies.rb:236:in `load_dependency'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/activ
e_support/dependencies.rb:251:in `require'
        from C:/Ruby/acturevue/config.ru:4:in `block in <main>'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.r
b:51:in `instance_eval'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.r
b:51:in `initialize'
        from C:/Ruby/acturevue/config.ru:1:in `new'
        from C:/Ruby/acturevue/config.ru:1:in `<main>'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.r
b:40:in `eval'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.r
b:40:in `parse_file'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb
:200:in `app'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/comm
ands/server.rb:46:in `app'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb
:301:in `wrapped_app'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb
:252:in `start'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/comm
ands/server.rb:70:in `start'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/comm
ands.rb:55:in `block in <top (required)>'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/comm
ands.rb:50:in `tap'
        from C:/Ruby/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/comm
ands.rb:50:in `<top (required)>'
        from script/rails:6:in `require'

我无法理解的是,昨天一切正常!今天早上,Windows 更新了,所以也许有一个链接,不是吗?

此外,我无法访问,localhost:3000但我可以连接到 PhpMyAdmin 的登录页面(在写入我的登录名/密码后它拒绝我的连接):localhost:81

在写这篇文章之前我找到了一些解决方案,但没有人为我工作!

提前致谢。

更新

这是我的 db.yml :

# And be sure to use new-style password hashing:
#   http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
  adapter: mysql
  encoding: utf8
  reconnect: false
  database: acturevue_development
  pool: 5
  username: root
  password: password
  host: localhost

更新 Gemfile 以查看 gem 是否可能是问题所在:

    source 'http://rubygems.org'

gem 'rails', '3.2.8'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'mysql'



# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'


gem 'geocoder'
gem 'gmaps4rails'
gem "bootstrap-sass", ">= 2.1.0.0"

gem "rolify", ">= 3.2.0"
gem "simple_form", ">= 2.0.3"
gem "paperclip", "~> 3.0"
4

2 回答 2

3

您必须为 mysql 指定 sockect

development:
 adapter: mysql
 encoding: utf8
 reconnect: false
 database: acturevue_development
 pool: 5
 username: root
 password: password
 host: localhost
 socket: /opt/lampp/var/mysql/mysql.sock //this path must point to your mysql socket

ps 你需要在Linux和Windows下都指定这个选项,在Mac OS下不完全确定。

于 2012-11-16T11:12:46.017 回答
0

试试下面的。

在宝石文件中

宝石'mysql','2.8.1'

在数据库.yml

发展:

adapter: mysql
 encoding: utf8
  reconnect: false
  database: acturevue_development
  pool: 5
  username: root
 password: password
  host: 127.0.0.0

希望它对你有用:)

于 2013-04-09T08:28:41.503 回答