###前提・実現したいこと
デプロイしたrailsアプリをサーバにおいているmysqlサーバに接続したいです。
そのためにとりあえず、
サーバにMysqlを設置し、ローカルのrailsアプリからの接続を試みています。
###発生している問題・エラーメッセージ
$ RAILS_ENV=production rake db:schema:load rake aborted! Mysql2::Error: Can't connect to MySQL server on 'xxx.xx.xxx.xx' (113)
###該当のソースコード
MySQLの設定から書いていきます。
以後、私のIPアドレスはxxx.xx.xxx.xxとします。
【サーバ側】
% SET PASSWORD FOR 'root'@'localhost' = PASSWORD('パスワード'); $ CREATE DATABASE anime_production DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; $ GRANT ALL ON anime_production.* TO 'anime'@'xxx.xx.xxx.xx'; $ SET PASSWORD FOR 'anime'@'xxx.xx.xxx.xx' = PASSWORD('パスワード');
【database.yml】
production: adapter: mysql2 database: anime_production username: anime password: パスワード host: xxx.xx.xxx.xx encoding: utf8 socket: /var/lib/mysql/mysql.sock
###試したこと
こちらを参考にmysqlの設定を行いました。
上記、database.yml内のhostをいくつか変更して試しました。
ver 127.0.0.1
RAILS_ENV=production rake db:schema:load rake aborted! Mysql2::Error: Can't connect to MySQL server on '127.0.0.1' (111)
ver localhost
RAILS_ENV=production rake db:schema:load rake aborted! Mysql2::Error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)
ちなみにですが、
pingはxxx.xx.xxx.xx・127.0.0.1・localhostいずれも接続を確認できています!
回答3件
あなたの回答
tips
プレビュー