0

我的 Rails 环境是

导轨:3.2.14,

红宝石:1.9.3,

系统:ubuntu

mysql: 5.5.32-0ubuntu0.12.04.1

我创建了一个 mysql 数据库,并测试数据库,我从 windows.so 中的 mysql 工作台连接它,所以我想证明,我在 ubuntu 中的 mysql 数据库运行正确

但是,当我在浏览器中运行网站时,出现错误:activerecord::connectionnotestablished。

完整的跟踪是:

activerecord (3.2.14) lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in retrieve_connection' activerecord (3.2.14) lib/active_record/connection_adapters/abstract/connection_specification.rb:171:inretrieve_connection' activerecord (3.2.14) lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in connection' activerecord (3.2.14) lib/active_record/query_cache.rb:67:inrescue in call' activerecord (3.2.14) lib/active_record/query_cache.rb:61:in call' activerecord (3.2.14) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:incall' actionpack (3.2.14) lib/action_dispatch/middleware/callbacks.rb:28:in block in call' activesupport (3.2.14) lib/active_support/callbacks.rb:405:inrun_72338529_call_445636797__callbacks' activesupport (3.2.14) lib/active_support/callbacks.rb:405:in __run_callback' activesupport (3.2.14) lib/active_support/callbacks.rb:385:in_run_call_callbacks' activesupport (3.2.14) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (3.2.14) lib/action_dispatch/middleware/callbacks.rb:27:incall' actionpack (3.2.14) lib/action_dispatch/middleware/reloader.rb:65:in call' actionpack (3.2.14) lib/action_dispatch/middleware/remote_ip.rb:31:incall' actionpack (3.2.14) lib/action_dispatch/middleware/debug_exceptions.rb:16:in call' actionpack (3.2.14) lib/action_dispatch/middleware/show_exceptions.rb:56:incall' railties (3.2.14) lib/rails/rack/logger.rb:32:in call_app' railties (3.2.14) lib/rails/rack/logger.rb:16:inblock in call' activesupport (3.2.14) lib/active_support/tagged_logging.rb:22:in tagged' railties (3.2.14) lib/rails/rack/logger.rb:16:incall' actionpack (3.2.14) lib/action_dispatch/middleware/request_id.rb:22:in call' rack (1.4.5) lib/rack/methodoverride.rb:21:incall' rack (1.4.5) lib/rack/runtime.rb:17:in call' activesupport (3.2.14) lib/active_support/cache/strategy/local_cache.rb:72:incall' rack (1.4.5) lib/rack/lock.rb:15:in call' actionpack (3.2.14) lib/action_dispatch/middleware/static.rb:63:incall' railties (3.2.14) lib/rails/engine.rb:484:in call' railties (3.2.14) lib/rails/application.rb:231:incall' rack (1.4.5) lib/rack/content_length.rb:14:in call' railties (3.2.14) lib/rails/rack/log_tailer.rb:17:incall' rack (1.4.5) lib/rack/handler/webrick.rb:59:in service' /home/hxh/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/webrick/httpserver.rb:138:inservice' /home/hxh/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/webrick/httpserver.rb:94:in run' /home/hxh/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/webrick/server.rb:191:inblock in start_thread'

database.yml的是:

development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: r4rmusic_development
  pool: 5
  username: root
  password:123 
  host:127.0.0.1
  socket: /var/run/mysqld/mysqld.sock

Gemfile的是:

source 'https://rubygems.org'
gem 'rails', '3.2.14'
gem 'mysql2'

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1' 

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

请帮我

4

2 回答 2

0

尝试设置和host: localhost删除socketdatabase.yml

于 2013-08-23T10:44:44.680 回答
0

仅从 database.yml 中删除套接字:/var/run/mysqld/mysqld.sock。它会起作用的。

于 2013-08-23T10:53:26.093 回答