mysql - Rails 4 mysql2 error when deploying to production -
i've got ubuntu virtual server (digital ocean droplet) set capistrano 3. i've gotten of directories set , project directory has current folder in it, containing config/database.yml
file. can't deployed run. gets stuck on rake db:migrate
phase. rake assets:precompile
works, think must database.yml
file. "production" block looks this:
config/database.yml (production part)
production: adapter: mysql2 encoding: utf8 database: capstone_production username: <%= env['database_username'] %> password: <%= env['database_password'] %> host: localhost port: /var/run/mysqld/mysqld.sock
i have checked file valid yaml yamllint utility. also, environment variables echo (root) credentials able use mysql login. when run cap production deploy:check
, good. however, running cap production deploy
okay until gets rake db:migrate
capistrano process. aborts , throws this:
the deploy has failed error: #<sshkit::runner::executeerror: exception while executing on host 107.170.105.223: exception while executing on host 107.170.105.223: rake exit status: 1 rake stdout: rake aborted! mysql2::error: access denied user 'root'@'localhost' (using password: no) /home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/gems/mysql2-0.3.20/lib/mysql2/client.rb:70:in `connect' /home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/gems/mysql2-0.3.20/lib/mysql2/client.rb:70:in `initialize' /home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `new' /home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `mysql2_connection' /home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:435:in `new_connection' /home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:445:in `checkout_new_connection' /home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `acquire_connection' /home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout' /home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in `checkout' /home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection' /home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection' /home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection' /home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_handling.rb:113:in `retrieve_connection' /home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/connection_handling.rb:87:in `connection' /home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/migration.rb:916:in `initialize' /home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/migration.rb:814:in `new' /home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/migration.rb:814:in `up' /home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/migration.rb:792:in `migrate' /home/deploy/apps/capstone_project/shared/bundle/ruby/2.1.0/bundler/gems/rails-331210df7c8a/activerecord/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>' tasks: top => db:migrate (see full trace running task --trace) rake stderr: nothing written
i've tried many combinations of yaml syntax , restarted mysql server, puma server, , nginx server on , on again. crazy, please help.
update
the problem seems stem this:
mysql2::error: access denied user 'root'@'localhost' (using password: no)
from i've read in mysql docs, error thrown when try login without password. i've got right credentials - can hard code actual username , password yaml file , same error. reason when capistrano executes following command (via cap production deploy or cap production deploy:migrate), it's not including password database.yml:
info [85893e95] running ~/.rvm/bin/rvm default bundle exec rake db:migrate on 107.170.105.223 debug [85893e95] command: cd /home/deploy/apps/capstone_project/releases/20160205235633 && ( export rails_env="production" ; ~/.rvm/bin/rvm default bundle exec rake db:migrate )
how ensure capistrano executes migration locally in development?
thank you
Comments
Post a Comment