I'm building a Rails app production environment on EC2.
unicorn
At startupMySQL
I get a connection error with, but I can't figure out the cause even after reviewing the settings.
ec2-user @ ip ~ $bundle exec unicorn_rails -c config/unicorn.rb -E production -D
error
master failed to start, check stderr log for details
Log contents
Contents of /unicorn.stderr.log
I, [2020-09-14T06: 51: 56.022146 # 21711] INFO-: Refreshing Gem list
I, [2020-09-14T06: 51: 58.226567 # 21711] INFO-: listening on addr = 0.0.0.0:3000 fd = 9
E, [2020-09-14T06: 51: 58.336893 # 21711] ERROR-: Access denied for user'Username' @'localhost' (using password: YES) (Mysql2 :: Error :: ConnectionError)
・
・
・
ps -aef | grep mysql results
ec2-user 6564 6489 0 03:31 pts/1 00:00:00 grep --color = auto mysql
mysql 28647 1 0 September 14? 00:05:16/usr/sbin/mysqld
databese.yml
default:&default
adapter: sqlite3
pool:<% = ENV.fetch ("RAILS_MAX_THREADS") {5}%>
timeout: 5000
development:
adapter: mysql2
encording: utf8
database: app name_development
pool: 5
username: username
password: Password (set locally)
host: localhost
#Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test: test:
adapter: mysql2
encoding: utf8
reconnect: false
database: app name_test
pool: 5
username: username
password: Password (set locally)
host: localhost
production:
<<: * default
database:<% = Rails.application.credentials.db [: database]%>
username:<% = Rails.application.credentials.db [: username]%>
password:<% = Rails.application.credentials.db [: password]%>
socket:<% = Rails.application.credentials.db [: socket]%>
credentials.yml
db:
database: app name
username: root
password: Password (set on the instance)
socket: /var/lib/mysql/mysql.sock
master.key
I've reset it, but I don't know what other settings to review.
I would appreciate it if you could teach me just the files that should be checked.
Thanks for your cooperation.
Work environment
- macOS Catalina
- Amazon Linux2
- EC2
- MySQL
- Ruby on Rails6
With the suggestions of yu_1985database.yml
Was rewritten.
default:&default
adapter: mysql2
pool:<% = ENV.fetch ("RAILS_MAX_THREADS") {5}%>
timeout: 5000
encording: utf8
database: app name
pool: 5
username: root
password: password
host: localhost
When I tried to start it in this state, I could see such an error in the log.
(master failed to start, check stderr log for details
There is no change in the appearance)
I, [2020-09-16T06: 46: 26.296957 # 8946] INFO-: Refreshing Gem list
bundler: failed to load command: unicorn_rails (/home/ec2-user/.rbenv/versions/2.6.6/bin/unicorn_rails)
NoMethodError: Cannot load database configuration:
undefined method `[]'for nil: NilClass
・
・
・
We are currently investigating this error.
If i know about this error, please teach me.
-
Answer # 1
-
Answer # 2
I wrote a lot in the question, but when I looked at the connection settings, I somehow understood.
-E production
I'm trying to start with, so I'm trying to connect to the DB by reading the settings in production.The production settings
default
In addition to, it is written to use four pieces of information in credential.db.production: <<: * default database:<% = Rails.application.credentials.db [: database]%> username:<% = Rails.application.credentials.db [: username]%> password:<% = Rails.application.credentials.db [: password]%> socket:<% = Rails.application.credentials.db [: socket]%>
on the other hand
default
Isdefault:&default adapter: sqlite3 pool:<% = ENV.fetch ("RAILS_MAX_THREADS") {5}%> timeout: 5000
So the adapter
sqlite3
It remains.
I think that production also needs to have adapter set to mysql2 like other environments.
In other environments, the specified encoding and host should also be included in the settings properly.
Related articles
- ruby on rails - test code causes error when product information input is successful
- ruby - i want to resolve an error when installing gem byebug
- ruby on rails - i don't understand the content of the error
- error in building environment of ruby on rails
- ruby - please tell me the cause of the error when specifying model: of form_with
- ruby - no error message is displayed during new registration
- ruby - after new registration with devise, an error is displayed
- mysql - command error improvement
- ruby - i don't know the cause of the validation error in factorybot
- mysql - database connection error with local third xampp, wordpress installation
- ruby on rails - i get an error with rails db: create
- ruby - an error occurred when implementing the micropost search function using ransack
- ruby on rails - i get an error in a program that changes over time
- kubernetes - [k8s] kubectl command causes an error
- i get an error when i try to install mysql with bundle install [ruby on rails]
- ruby on rails - nomethoderror in itemscontroller # new error
- ruby - i got a routing error when i sent a comment
- ruby on rails - i get an error without being created
- ruby - resolve rspec mysql foreignkey error
- ruby - about error of update action when nesting
- javascript - i want to eliminate the full calender not being displayed when deploying on aws
- ruby - i entered secret_key_base, but http error 500 cannot be resolved
- ruby - it works fine in my local environment, but when i deploy it to aws, i get an error in mysql2 :: error: unknown column
- ruby - behavior that i do not know if rails can be started with unicorn
- ruby - aws unicorn cannot start master failed to start, check stderr log for details error
- ruby - resolve rspec mysql foreignkey error
- amazon ec2 - i'm being billed even though i'm shutting down my instance on aws ec2
- amazon ec2 - aws ec2 connection error with vscode remote-ssh plugin
- ruby - ssl_connect returned = 1 errno = 0 state = error: wrong version number
- ruby on rails - i want to solve the problem that "we're sorry, but something went wrong" is displayed in the productio
The environment construction was restarted from the beginning.
Thank you for your reply.