Note that there are some explanatory texts on larger screens.

plurals
  1. PORails Rubber gem with a mysql2 adapter - Access denied for user error
    primarykey
    data
    text
    <p>I'm trying to use a nice simple Rails app (1 model with 2 fields) to learn how to deploy an app to an Amazon Web Services (AWS) EC2 instance server using the mysql2 data adapter. I'm trying to use the Rubber Gem to do the deployment. Everything looks good (bootstrap &amp; deploy) until I try browsing the website. The apache2 error.log shows this error when I enter the URL for the index page of the model:</p> <pre><code>*** Exception PhusionPassenger::UnknownError in PhusionPassenger::Rack::ApplicationSpawner (Access denied for user ''@'blog.foo.com' to database 'blog_production' (Mysql2::Error)) </code></pre> <p>Why can't the mysql db be accessed? Everything looks good that Rubber setup.</p> <p>The full error.log data is</p> <pre><code>[ pid=19455 thr=19477020 file=utils.rb:176 time=2012-09-13 23:25:01.220 ]: *** Exception PhusionPassenger::UnknownError in PhusionPassenger::Rack::ApplicationSpawner (Access denied for user ''@'blog.foo.com' to database 'blog_production' (Mysql2::Error)) (process 19455, thread #&lt;Thread:0x00000002526438&gt;): from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `initialize' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:304:in `new_connection' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:323:in `checkout_new_connection' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block (2 levels) in checkout' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:261:in `loop' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:261:in `block in checkout' from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:260:in `checkout' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:162:in `connection' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:409:in `retrieve_connection' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:107:in `retrieve_connection' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in `connection' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/base.rb:701:in `table_exists?' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/base.rb:792:in `attribute_names' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/actionpack-3.1.0/lib/action_controller/metal/params_wrapper.rb:168:in `_set_wrapper_defaults' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/actionpack-3.1.0/lib/action_controller/metal/params_wrapper.rb:128:in `inherited' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/actionpack-3.1.0/lib/abstract_controller/railties/routes_helpers.rb:7:in `block (2 levels) in with' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/actionpack-3.1.0/lib/action_controller/railties/paths.rb:7:in `block (2 levels) in with' from /mnt/blog-production/releases/20120914032205/app/controllers/articles_controller.rb:1:in `&lt;top (required)&gt;' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `block in require' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:225:in `load_dependency' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:348:in `require_or_load' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:302:in `depend_on' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:214:in `require_dependency' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/engine.rb:416:in `block (2 levels) in eager_load!' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/engine.rb:415:in `each' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/engine.rb:415:in `block in eager_load!' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/engine.rb:413:in `each' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/engine.rb:413:in `eager_load!' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application/finisher.rb:51:in `block in &lt;module:Finisher&gt;' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/initializable.rb:25:in `instance_exec' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/initializable.rb:25:in `run' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/initializable.rb:50:in `block in run_initializers' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/initializable.rb:49:in `each' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/initializable.rb:49:in `run_initializers' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application.rb:92:in `initialize!' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/railtie/configurable.rb:30:in `method_missing' from /mnt/blog-production/releases/20120914032205/config/environment.rb:5:in `&lt;top (required)&gt;' from config.ru:3:in `require' from config.ru:3:in `block in &lt;main&gt;' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in `instance_eval' from /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in `initialize' from config.ru:1:in `new' from config.ru:1:in `&lt;main&gt;' from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.12/lib/phusion_passenger/rack/application_spawner.rb:225:in `eval' from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.12/lib/phusion_passenger/rack/application_spawner.rb:225:in `load_rack_app' from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.12/lib/phusion_passenger/rack/application_spawner.rb:157:in `block in initialize_server' from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.12/lib/phusion_passenger/utils.rb:572:in `report_app_init_status' from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.12/lib/phusion_passenger/rack/application_spawner.rb:154:in `initialize_server' from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb:204:in `start_synchronously' from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb:180:in `start' from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.12/lib/phusion_passenger/rack/application_spawner.rb:129:in `start' from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb:253:in `block (2 levels) in spawn_rack_application' from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add' from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb:246:in `block in spawn_rack_application' from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize' from &lt;internal:prelude&gt;:10:in `synchronize' from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize' from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application' from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application' from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application' from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop' from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously' from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.12/helper-scripts/passenger-spawn-server:99:in `&lt;main&gt;' [ pid=19516 thr=140129381447488 file=ext/apache2/Hooks.cpp:862 time=2012-09-13 23:25:01.326 ]: Unexpected error in mod_passenger: Cannot spawn application '/mnt/blog-production/releases/20120914032205': An error occured while spawning the application. Backtrace: in 'virtual Passenger::SessionPtr Passenger::ApplicationPool::Client::get(const Passenger::PoolOptions&amp;)' (Client.h:742) in 'Passenger::SessionPtr Hooks::getSession(const Passenger::PoolOptions&amp;)' (Hooks.cpp:294) in 'int Hooks::handleRequest(request_rec*)' (Hooks.cpp:563) </code></pre> <p>The config/database.yml file on the deployed sever is </p> <pre><code>production: adapter: mysql2 encoding: utf8 database: blog_production username: blog password: host: blog.foo.com pool: 5 </code></pre> <p>Is there any additional information that would help track down the problem?</p> <p>I'm going on two weeks now trying to get the website deployed at AWS. One of these days I'm going to git pay dirt.</p> <p>Thanks, Russ</p> <p>I saw the password field is blank, so set a value for the db_pass variable in the rubber-mysql.yml</p> <pre><code>db_user: "#{app_name[0,16]}" db_pass: kickback db_name: "#{app_name}_#{Rubber.env}" </code></pre> <p>I tried just doing a <code>cap rubber:bootstrap</code> followed by a <code>cap deploy</code> hoping that would fill in the password value on the server in the config/database.yml file. That didn't work, so I did a full <code>cap rubber:create_staging</code>. The yml file now has the password filled in </p> <pre><code>production: adapter: mysql2 encoding: utf8 database: blog_production username: blog password: kickback host: blog.foo.com pool: 5 </code></pre> <p>But the tail end of the create_staging command showed this error</p> <pre><code> * executing "cd /mnt/blog-production/releases/20120914041247 &amp;&amp; bundle exec rake RAILS_ENV=production db:migrate" servers: ["blog.foo.com"] [blog.foo.com] executing command ** [out :: blog.foo.com] rake aborted! ** [out :: blog.foo.com] ** [out :: blog.foo.com] Access denied for user 'blog'@'blog.foo.com' (using password: YES) ** [out :: blog.foo.com] ** [out :: blog.foo.com] ** [out :: blog.foo.com] Tasks: TOP =&gt; db:migrate ** [out :: blog.foo.com] ** [out :: blog.foo.com] (See full trace by running task with --trace) ** [out :: blog.foo.com] command finished in 25336ms failed: "/bin/bash -l -c 'cd /mnt/blog-production/releases/20120914041247 &amp;&amp; bundle exec rake RAILS_ENV=production db:migrate'" on blog.foo.com </code></pre> <p>What to try next? Maybe trying the <code>rake db:migrate</code> manually. </p> <pre><code>$ RAILS_ENV=production rake db:migrate --trace ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment Rails Error: Unable to access log file. Please ensure that /mnt/blog-production/releases/20120914041247/log/production.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed. ** Invoke db:load_config (first_time) ** Invoke rails_env (first_time) ** Execute rails_env ** Execute db:load_config ** Execute db:migrate rake aborted! Access denied for user 'blog'@'blog.foo.com' (using password: YES) /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `initialize' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:304:in `new_connection' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:323:in `checkout_new_connection' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block (2 levels) in checkout' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:261:in `loop' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:261:in `block in checkout' /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:260:in `checkout' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:162:in `connection' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:409:in `retrieve_connection' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:107:in `retrieve_connection' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in `connection' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/migration.rb:633:in `initialize' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/migration.rb:549:in `new' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/migration.rb:549:in `up' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/migration.rb:530:in `migrate' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/railties/databases.rake:161:in `block (2 levels) in &lt;top (required)&gt;' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain' /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run' /mnt/blog-production/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `&lt;top (required)&gt;' /usr/local/rvm/gems/ruby-1.9.2-p290@global/bin/rake:19:in `load' /usr/local/rvm/gems/ruby-1.9.2-p290@global/bin/rake:19:in `&lt;main&gt;' /usr/local/rvm/gems/ruby-1.9.2-p290/bin/ruby_noexec_wrapper:14:in `eval' /usr/local/rvm/gems/ruby-1.9.2-p290/bin/ruby_noexec_wrapper:14:in `&lt;main&gt;' Tasks: TOP =&gt; db:migrate </code></pre> <p>Is it time for me to give up on using Rubber?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload