Access denied for user 'root'@'localhost' (using password: YES) even though i have added in mysql

Hi,

I am getting the error "Access denied for user 'root'@'localhost' (using password: YES)" in my application. I have granted full permissions for the device in mysql.

My applications runs perfectly fine. But if i keep the browser idle for some time and then try to load the page I get the above error. When I do ctrl + F5 few times the app is up and running.

Why am I getting such an error? The same code with the same DB is running fine in another system.

Any help is appreciated.

Regards, Madhu.

Could you show:

Operating system on which the server is running? Which Rails version? Is that database on the same server, same user, different server? (I presume you are going over TCP/IP ?)

Content of config/database.yml (hide the password !). Do you see an error trace in your log file (grep for FATAL or ‘500’)

Thanks,

Peter

I am running it on windows 2003 VM. Rails versions in 2.3.5. Database is in another server not the same server.

Here is the database.yml conf

development:   adapter: mysql   encoding: utf8   database: db   username: root   password: ***   host: 172.16.1.50   port: 3306

Yes the request is through TCP/IP.

Below is the error trace:

/!\ FAILSAFE /!\ Tue Jan 03 18:38:51 +0530 2012   Status: 500 Internal Server Error   Lost connection to MySQL server during query     c:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapte rs/mysql_adapter.rb:597:in `real_connect'     c:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapte rs/mysql_adapter.rb:597:in `connect'     c:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapte rs/mysql_adapter.rb:203:in `initialize'     c:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapte rs/mysql_adapter.rb:75:in `new'     c:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapte rs/mysql_adapter.rb:75:in `mysql_connection'     c:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapte rs/abstract/connection_pool.rb:223:in `send'     c:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapte rs/abstract/connection_pool.rb:223:in `new_connection'     c:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapte rs/abstract/connection_pool.rb:245:in `checkout_new_connection'     c:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapte rs/abstract/connection_pool.rb:188:in `checkout'     c:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapte rs/abstract/connection_pool.rb:184:in `loop'     c:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapte rs/abstract/connection_pool.rb:184:in `checkout'     c:/Ruby187/lib/ruby/1.8/monitor.rb:242:in `synchronize'     c:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapte rs/abstract/connection_pool.rb:183:in `checkout'     c:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapte rs/abstract/connection_pool.rb:98:in `connection'     c:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapte rs/abstract/connection_pool.rb:326:in `retrieve_connection'     c:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapte rs/abstract/connection_specification.rb:123:in `retrieve_connection'     c:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapte rs/abstract/connection_specification.rb:115:in `connection'     c:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:9: in `cache'     c:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:28 :in `call'     c:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapte rs/abstract/connection_pool.rb:361:in `call'     c:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/string_coercion .rb:25:in `call'     c:/Ruby187/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in `call'     c:/Ruby187/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:in `call'     c:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/params_parser.r b:15:in `call'     c:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/cookie_ store.rb:93:in `call'     c:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/failsafe.rb:26: in `call'     c:/Ruby187/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'     c:/Ruby187/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `synchronize'     c:/Ruby187/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'     c:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:1 14:in `call'     c:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/reloader.rb:34: in `run'     c:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:1 08:in `call'     c:/Ruby187/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/rack/static.rb:31:in `call'     c:/Ruby187/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in `call'     c:/Ruby187/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `each'     c:/Ruby187/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `call'     c:/Ruby187/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/rack/log_tailer.rb:17:in `call'     c:/Ruby187/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb:13:in `call'     c:/Ruby187/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/chunked.rb:15:in `call'     c:/Ruby187/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:64:in `process'

    c:/Ruby187/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mingw32/lib/mongrel.rb:159:in `proce ss_client'     c:/Ruby187/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mingw32/lib/mongrel.rb:158:in `each'

    c:/Ruby187/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mingw32/lib/mongrel.rb:158:in `proce ss_client'     c:/Ruby187/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mingw32/lib/mongrel.rb:285:in `run'     c:/Ruby187/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mingw32/lib/mongrel.rb:285:in `initi alize'     c:/Ruby187/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mingw32/lib/mongrel.rb:285:in `new'     c:/Ruby187/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mingw32/lib/mongrel.rb:285:in `run'     c:/Ruby187/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mingw32/lib/mongrel.rb:268:in `initi alize'     c:/Ruby187/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mingw32/lib/mongrel.rb:268:in `new'     c:/Ruby187/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mingw32/lib/mongrel.rb:268:in `run'     c:/Ruby187/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:34:in `run'     c:/Ruby187/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:111     c:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require '     c:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'     script/server:3

Thank you :slight_smile:

Sorry, I have little experience with this combination. I hope others can help here.

Peter

hmm.. try to add in config/database.yml below `password` this line: ` reconnect: true`