Jump to content

The ultimate community for Ruby on Rails developers.


Photo

ActiveRecord::ConnectionNotEstablished

connectionnotestablished mysq

  • Please log in to reply
2 replies to this topic

#1 jschrock1

jschrock1

    Dispatcher

  • Members
  • 45 posts
  • LocationIndianapolis

Posted 23 October 2013 - 11:17 PM

Things were going so well, and then..  I created a rails app, this time using MySql rather than sqlite3.  Went through the Micheal tutorial again, set up the static_pages and added a user model/table.  I ran the rails generates successfully, db:migrate successfully and it created the database successfully and created the user table successfully.  When I try to access this simple web app using localhost:3000  I received the following error.  Note I can log into mysql successfully via mysql at the command line and connect to the database.  The gem list and database.yml is provided below.  Im using rails 4.0.0  mysql 5.6.  its quite puzzling as I've scoured the forums, found folks with similar problems, but nothing that resolved my issue.  Any ideas would be greatly appreciated and thank you in advance. 

ActiveRecord::ConnectionNotEstablished

A few lines of trace is as follows:

Application Trace | Framework Trace | Full Trace

activerecord (4.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in `retrieve_connection'
activerecord (4.0.0) lib/active_record/connection_handling.rb:79:in `retrieve_connection'
activerecord (4.0.0) lib/active_record/connection_handling.rb:53:in `connection'
activerecord (4.0.0) lib/active_record/query_cache.rb:51:in `restore_query_cache_settings'
activerecord (4.0.0) lib/active_record/query_cache.rb:43:in `rescue in call'
activerecord (4.0.0) lib/active_record/query_cache.rb:32:in `call'
activerecord (4.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
activerecord (4.0.0) lib/active_record/migration.rb:369:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.0.0) lib/active_support/callbacks.rb:373:in `_run__547861565__call__callbacks'
activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'

My database.yml:  (note I tried replacing localhost with 127.0.0.1  or whatever that address is) but did not work.

 

development:
  adapter: mysql2
  encoding: utf8
  database: db/****   (*** indicating then name of the database)
  pool: 5
  username: root
  password: root
  host: localhost
  port:3306
  timeout: 5000

 

My gen list shows:

 

actionmailer (4.0.0, 3.2.13)
actionpack (4.0.0, 3.2.13)
activemodel (4.0.0, 3.2.13)
activerecord (4.0.0, 3.2.13)
activerecord-deprecated_finders (1.0.3)
activerecord-sqlserver-adapter (3.2.10)
activeresource (3.2.13)
activesupport (4.0.0, 3.2.13)
arel (4.0.1, 4.0.0, 3.0.2)
atomic (1.1.14)
bcrypt-ruby (3.0.1 x86-mingw32)
bigdecimal (1.1.0)
bootstrap-sass (2.3.2.0)
bootstrap-will_paginate (0.0.9)
builder (3.1.4, 3.0.4)
bundler (1.3.4)
capybara (2.1.0)
celluloid (0.15.2)
childprocess (0.3.9, 0.3.6)
coderay (1.0.9)
coffee-rails (4.0.1, 4.0.0, 3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.6.3, 1.6.1)
diff-lcs (1.2.4)
erubis (2.7.0)
execjs (2.0.2, 2.0.1, 1.4.0)
factory_girl (4.2.0)
factory_girl_rails (4.2.1)
faker (1.1.2)
ffi (1.9.0 x86-mingw32)
formatador (0.2.4)
guard (2.2.1, 2.1.1, 1.8.3)
guard-rspec (2.5.0)
guard-spork (1.5.0)
hike (1.2.3, 1.2.1)
i18n (0.6.5, 0.6.1)
io-console (0.3)
jbuilder (1.5.2, 1.5.1, 1.0.2)
journey (1.0.4)
jquery-rails (3.0.4, 2.2.1)
json (1.8.1, 1.8.0, 1.5.5)
listen (2.1.1, 1.3.1)
lumberjack (1.0.4)
mail (2.5.4, 2.5.3)
method_source (0.8.2)
mime-types (1.25, 1.21)
mini_portile (0.5.1)
minitest (4.7.5, 2.5.1)
multi_json (1.8.2, 1.8.0, 1.7.1)
mysql (2.9.1 ruby x86-mingw32, 2.8.1 x86-mingw3
mysql2 (0.3.11 x86-mingw32)
nokogiri (1.6.0 x86-mingw32)
pg (0.15.1 x86-mingw32, 0.14.1 x86-mingw32)
polyglot (0.3.3)
pry (0.9.12.2 i386-mingw32)
rack (1.5.2, 1.4.5)
rack-cache (1.2)
rack-ssl (1.3.3)
rack-test (0.6.2)
rails (4.0.0, 3.2.13)
rails_12factor (0.0.2)
rails_serve_static_assets (0.0.1)
rails_stdout_logging (0.0.2)
railties (4.0.0, 3.2.13)
rake (10.1.0, 10.0.3, 0.9.2.2)
rb-fsevent (0.9.3)
rb-inotify (0.9.2)
rb-kqueue (0.2.0)
rb-readline (0.4.2)
rdoc (3.12.2, 3.9.5)
rspec (2.13.0)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
rspec-mocks (2.13.1)
rspec-rails (2.13.1)
rubyzip (0.9.9)
sass (3.2.12, 3.2.10, 3.2.7)
sass-rails (4.0.1, 4.0.0, 3.2.6)
sdoc (0.3.20)
selenium-webdriver (2.35.1)
slop (3.4.6)
spork (1.0.0rc4 x86-mingw32)
spork-rails (4.0.0)
sprockets (2.10.0, 2.2.2)
sprockets-rails (2.0.1, 2.0.0)
sqlite3 (1.3.8 x86-mingw32, 1.3.7 x86-mingw32)
sqlite3-ruby (1.3.3)
thor (0.18.1, 0.17.0)
thread_safe (0.1.3)
tilt (1.4.1, 1.3.6)
timers (1.1.0)
tiny_tds (0.5.1 x86-mingw32)
treetop (1.4.15, 1.4.12)
turbolinks (1.3.0, 1.1.1)
tzinfo (0.3.38, 0.3.37)
uglifier (2.2.1, 2.1.1)
websocket (1.0.7)
will_paginate (3.0.4)
win32-process (0.7.4, 0.7.3)
win32console (1.3.2 x86-mingw32)
xpath (2.0.0)
 



#2 jschrock1

jschrock1

    Dispatcher

  • Members
  • 45 posts
  • LocationIndianapolis

Posted 24 October 2013 - 01:25 AM

I solved my problem thanks to a post that indicated to run Yaml (spelling)..  Anyway the problem boils down to the database.,yml file.  I didn't have spaces after the :.  That was it!  hours of searching came down to adding a space after the : in this file, good god!  ok, hope this helps anybody else that is having similar problem...



#3 specious

specious

    Passenger

  • Members
  • 3 posts

Posted 25 October 2013 - 08:39 AM

Just an observation about your database.yml file - generally speaking, logging in as root is normally a bad idea. Even in test. Set up a user in MySQL, it takes 2 minutes...






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users