0
votes

my rails environment is

Rails: 3.2.14,

ruby: 1.9.3,

system: ubuntu

mysql: 5.5.32-0ubuntu0.12.04.1

I create a mysql database,and to test the database, I connect It from my mysql workbench in windows.so, I want to show that,my mysql database in ubuntu is run correctly

but ,when I run the website in browser , I get the error: activerecord::connectionnotestablished .

the full trace is:

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'

my database.yml is:

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

my Gemfile is:

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'

please help me

2
Please can you try by adding pool in database yml.Mohanraj
my database.yml include ' pool: 5'HXH

2 Answers

0
votes

Try to set host: localhost and remove socket from database.yml

0
votes

Remove socket: /var/run/mysqld/mysqld.sock from database.yml only. It will work.