ActiveRecord::ConnectionNotEstablished

Hi,

I am trying the tutorial in:

when I try to navigate to http://localhost:3000 after the 4.3 change
I get the error : ActiveRecord::ConnectionNotEstablished
and I don’t know how to solve it
the database.yml file is:
adapter => mysql
host => 127.0.0.1
database => blog
username => root
password => *****

my gems:
rails 3.1.3
activerecord 3.1.3
mysql 2.8.1

What to do, please?
regards

On 26 February 2012 21:51, rubix Rubix [email protected] wrote:

database => blog
username => root
password => *****

Did rake db:create that you did earlier succeed. I note that you are
using mysql rather than sqlite, is that intentional?
Can you access the db via your mysql server by other means?
I think you should probably specify mysql2 as the adaptor in
database.yml. At least that is what I have.

Colin

yes rake db:create succeded, it ended without error
I used mysql2 and didn’t work too

hi, this is the stack trace:

activerecord (3.1.3)
lib/active_record/connection_adapters/abstract/connection_pool.rb:409:in
retrieve_connection' activerecord (3.1.3) lib/active_record/connection_adapters/abstract/connection_specification.rb:115:inretrieve_connection’
activerecord (3.1.3)
lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in
connection' activerecord (3.1.3) lib/active_record/query_cache.rb:67:inrescue in
call’
activerecord (3.1.3) lib/active_record/query_cache.rb:61:in call' activerecord (3.1.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:477:incall’
actionpack (3.1.3) lib/action_dispatch/middleware/callbacks.rb:29:in
block in call' activesupport (3.1.3) lib/active_support/callbacks.rb:392:in_run_call_callbacks’
activesupport (3.1.3) lib/active_support/callbacks.rb:81:in
run_callbacks' actionpack (3.1.3) lib/action_dispatch/middleware/callbacks.rb:28:incall’
actionpack (3.1.3) lib/action_dispatch/middleware/reloader.rb:68:in
call' rack (1.3.6) lib/rack/sendfile.rb:101:incall’
actionpack (3.1.3) lib/action_dispatch/middleware/remote_ip.rb:48:in
call' actionpack (3.1.3) lib/action_dispatch/middleware/show_exceptions.rb:47:incall’
railties (3.1.3) lib/rails/rack/logger.rb:13:in call' rack (1.3.6) lib/rack/methodoverride.rb:24:incall’
rack (1.3.6) lib/rack/runtime.rb:17:in call' activesupport (3.1.3) lib/active_support/cache/strategy/local_cache.rb:72:incall’
rack (1.3.6) lib/rack/lock.rb:15:in call' actionpack (3.1.3) lib/action_dispatch/middleware/static.rb:53:incall’
railties (3.1.3) lib/rails/engine.rb:456:in call' rack (1.3.6) lib/rack/content_length.rb:14:incall’
railties (3.1.3) lib/rails/rack/log_tailer.rb:14:in call' rack (1.3.6) lib/rack/handler/webrick.rb:59:inservice’
C:/Ruby192/lib/ruby/1.9.1/webrick/httpserver.rb:111:in service' C:/Ruby192/lib/ruby/1.9.1/webrick/httpserver.rb:70:inrun’
C:/Ruby192/lib/ruby/1.9.1/webrick/server.rb:183:in `block in
start_thread’

and I switch to mysql2
regards

On 26 February 2012 22:55, rubix Rubix [email protected] wrote:

yes rake db:create succeded, it ended without error
I used mysql2 and didn’t work too

Can you post the full error message and stack trace? Use mysql2.

Colin


Posted via http://www.ruby-forum.com/.


You received this message because you are subscribed to the Google G. “Ruby
on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


gplus.to/clanlaw

rake db:create : ends without any message
rake db:migrate: ends with error message

** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
rake aborted!
adapter => mysql host => 127.0.0.1 database => blog username => root
password = root

database is not configured
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connect
ion_adapters/abstract/connection_specification.rb:62:in
establish_connection' C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connect ion_adapters/abstract/connection_specification.rb:60:inestablish_connection’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connect
ion_adapters/abstract/connection_specification.rb:55:in
establish_connection' C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/railtie .rb:69:inblock (2 levels) in class:Railtie
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/lazy_
load_hooks.rb:36:in instance_eval' C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/lazy_ load_hooks.rb:36:inexecute_hook’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/lazy_
load_hooks.rb:43:in block in run_load_hooks' C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/lazy_ load_hooks.rb:42:ineach’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/lazy_
load_hooks.rb:42:in run_load_hooks' C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/base.rb :2190:in<top (required)>’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/railtie
s/databases.rake:6:in block (2 levels) in <top (required)>' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:incall’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in
block in execute' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:ineach’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in
execut e' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:inblock
in invoke_with_call_chain’
C:/Ruby192/lib/ruby/1.9.1/monitor.rb:201:in mon_synchronize' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:ininvoke
_with_call_chain’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:176:in
block in invoke_prerequisites' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:ineach’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in
invoke _prerequisites' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:157:inblock
in invoke_with_call_chain’
C:/Ruby192/lib/ruby/1.9.1/monitor.rb:201:in mon_synchronize' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:ininvoke
_with_call_chain’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in
invoke ' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:ininvoke_task’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in
block (2 levels) in top_level' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in
each’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in
block in top_level' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:instandard_exception_handling’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in
top_level' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in
block in run’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in
standard_exception_handling' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in
run’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in <top (required) ' C:/Ruby192/bin/rake:19:inload’
C:/Ruby192/bin/rake:19:in `’
Tasks: TOP => db:migrate => db:load_config

regards,

On 27 February 2012 20:11, rubix Rubix [email protected] wrote:

connection' activesupport (3.1.3) lib/active_support/callbacks.rb:81:in railties (3.1.3) lib/rails/rack/logger.rb:13:in call’
C:/Ruby192/lib/ruby/1.9.1/webrick/httpserver.rb:111:in service' C:/Ruby192/lib/ruby/1.9.1/webrick/httpserver.rb:70:in run’
C:/Ruby192/lib/ruby/1.9.1/webrick/server.rb:183:in `block in
start_thread’

and I switch to mysql2
regards

Can you repeat rake db:create and copy/paste the complete command line
and the results here. Then do the same for rake db:migrate.

If those work then start the server and browse to
http://localhost:3000 and show the complete output from the server
window, except you can just show the start of the stack trace if it is
the same as above. It is a lot less annoying to have too much
information than it is to have to keep going back and asking for more.

Finally post the whole of database.yml.

Colin

On 27 February 2012 21:29, rubix Rubix [email protected] wrote:

rake aborted!
adapter => mysql host => 127.0.0.1 database => blog username => root
password =

aggouni database is not configured

I am not sure you should have told us the password. I thought you
said you had switched to mysql2. The above says you are using mysql.
Try again with mysql2. Don’t just say it makes no difference, post
the result again.

Also have you have confirmed that the database has been created? You
can do this using mysql command line.

Colin

On 27 February 2012 22:17, rubix Rubix [email protected] wrote:

It was just a copy/paste error, and I change it as fast as possible
please erase the part of the pwd

Too late, it is distributed around the internet now, there is no way
of deleting it. I suggest you change the password and if you have
used that password for anything else then you change it there too.
Quickly.

else I try it too with mysql2 and I had the same message

It is impossible that it had exactly the same message. I specifically
asked that you don’t just say that it made no difference, I asked that
you post the result again. I cannot help unless you provide all the
information I ask for.

I create the db manually with Mysql workbench
regards,

It is a pity you did not mention that before. When you said that rake
db:create worked ok then that suggests that it successfully created
the database, but now you are telling me that you did not create the
db that way. At the start you said you were working through a
tutorial, did it not tell you to create the db using rake db:create?

I think you should remove the database and see if rake db:create will
create it. If not then post the result here. Is there anything else
of possible significance that you have not told us?

Colin

It was just a copy/paste error, and I change it as fast as possible
please erase the part of the pwd
else I try it too with mysql2 and I had the same message
I create the db manually with Mysql workbench
regards,

On 28 February 2012 20:25, rubix Rubix [email protected] wrote:

password:
** Execute db:create
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in
C:/Ruby192/lib/ruby/1.9.1/monitor.rb:201:in mon_synchronize' each’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in <top (required)>' C:/Ruby192/bin/rake:19:in load’
C:/Ruby192/bin/rake:19:in `’
Tasks: TOP => db:create

Is it a missing gem?

Have you got
gem ‘mysql2’
in Gemfile, and have you run bundle install?

If you think you have then do it again anyway, check whether it still
fails, and post the output from bundle install and post Gemfile.

Colin

Ok,

I dropped the schema blog, I change the pwd and I change the adapter
like this:
development:
adapter: mysql2
encoding: utf8
database: blog_dev
pool: 5
username: root
password:
socket: /tmp/mysql.sock

I execute rake db:create and I get the following error stack:

** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:create
rake aborted!
uninitialized constant Mysql2
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/railtie
s/databases.rake:81:in rescue in create_database' C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/railtie s/databases.rake:54:increate_database’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/railtie
s/databases.rake:42:in block (2 levels) in <top (required)>' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:incall’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in
block in execute' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:ineach’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in
execut e' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:inblock
in invoke_with_call_chain’
C:/Ruby192/lib/ruby/1.9.1/monitor.rb:201:in mon_synchronize' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:ininvoke
_with_call_chain’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in
invoke ' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-.9.2.2/lib/rake/application.rb:116:ininvoke_task’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-.9.2.2/lib/rake/application.rb:94:in
block (2 levels) in top_level' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-.9.2.2/lib/rake/application.rb:94:ineach’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-.9.2.2/lib/rake/application.rb:94:in
block in top_level' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-.9.2.2/lib/rake/application.rb:133:instandard_exception_handling’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-.9.2.2/lib/rake/application.rb:88:in
top_level' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-.9.2.2/lib/rake/application.rb:66:inblock in run’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-.9.2.2/lib/rake/application.rb:133:instandard_exception_handling' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-.9.2.2/lib/rake/application.rb:63:inrun’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in <top (required)>' C:/Ruby192/bin/rake:19:inload’
C:/Ruby192/bin/rake:19:in `’
Tasks: TOP => db:create

Is it a missing gem?

I found this too in internet, but I don’t know how to do it?
how to get gem mysql2 in gemfile and what gemfile exactly?

regards,

I changed the gem file and succeeded with the db:create and created the
three databases only for once after that I can’t use any of my mysql
database connections not only in ror applications
the message is : Access denied for user ‘root’@‘localhost’ (using
password: YES) (Mysql::AccessDeniedError)
I am using ruby on windows

this is an example of a database connection
ActiveRecord::Base.establish_connection(
:adapter => “mysql”,
:host => “127.0.0.1”,
:database => “database”,
:username => “root”,
:password => “*********”
)

regards,

On 28 February 2012 20:42, rubix Rubix [email protected] wrote:

I found this too in internet, but I don’t know how to do it?
how to get gem mysql2 in gemfile and what gemfile exactly?

The file is the file Gemfile in the root of your rails project (this
file is mentioned in the tutorial). I think maybe you would be best
to follow the tutorial /exactly/ for the moment, rather than trying to
use mysql. Then when you have worked through that simple one go on to
railstutorial.org (which is free to use online) which will introduce
you to more concepts and techniques, rather than hoping for people
here to help with every little issue you have.

Colin

I download the lib libmysql.dll
and I delete the line about password and It worked (i have a routing
error but this is not serious)