Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
capistranoでのデプロイ時に
Caused by:
SSHKit::Command::Failed: rake exit status: 1
rake stdout: Nothing written
rake stderr: rake aborted!
Mysql2::Error::ConnectionError: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
上記のエラーが出た。
MySQLサーバーと接続するタイミングで接続ができなくエラーが出た模様。
解決策としてはMySQLサーバーを再起動させることにより解決できる場合が多い。
EC2コンソール
$ sudo systemctl restart mysqld.service
上記のコマンドでMySQLサーバーを再起動させてから
ローカル
$ bundle exec cap production deploy
capistranoで自動デプロイできるようになる