前提・実現したいこと
自動デプロイ(capistrano使用)後、ローカルで下記のエラーが発生しています。
発生している問題・エラーメッセージ
unicornstderrlog
1ERROR -- : Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) (Mysql2::Error::ConnectionError)
試したこと
ローカルにmysql.sockファイルがあるか確認。
$ mysqladmin variables | grep socket | performance_schema_max_socket_classes | 10 | | performance_schema_max_socket_instances | 322 | | socket | /tmp/mysql.sock
databaseyml
1# MySQL. Versions 5.0 and up are supported. 2# 3# Install the MySQL driver 4# gem install mysql2 5# 6# Ensure the MySQL gem is defined in your Gemfile 7# gem 'mysql2' 8# 9# And be sure to use new-style password hashing: 10# http://dev.mysql.com/doc/refman/5.7/en/old-client.html 11# 12default: &default 13 adapter: mysql2 14 encoding: utf8 15 pool: 5 16 username: root 17 password: 18 socket: /tmp/mysql.sock 19 20development: 21 <<: *default 22 database: hogehoge_development 23 24# Warning: The database defined as "test" will be erased and 25# re-generated from your development database when you run "rake". 26# Do not set this db to the same as development or production. 27test: 28 <<: *default 29 database: hogehoge_test 30 31# As with config/secrets.yml, you never want to store sensitive information, 32# like your database password, in your source code. If your source code is 33# ever seen by anyone, they now have access to your database. 34# 35# Instead, provide the password as a unix environment variable when you boot 36# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database 37# for a full rundown on how to provide these environment variables in a 38# production deployment. 39# 40# On Heroku and other platform providers, you may have a full connection URL 41# available as an environment variable. For example: 42# 43# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" 44# 45# You can use this database configuration with: 46# 47# production: 48# url: <%= ENV['DATABASE_URL'] %> 49# 50production: 51 <<: *default 52 database: hogehoge_production 53 username: root 54 password: <%= ENV['DATABASE_PASSWORD'] %> 55 socket: /var/lib/mysql/mysql.sock 56
database.ymlの記述も問題ないかと思います。
ご教授のほど何卒よろしくお願いします。
補足情報(FW/ツールのバージョンなど)
ruby 2.6.3
rails 5.0.7.2
capistrano 3.11.1
nginx 1.16.1
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。