2
votes

I got some problems with deploying to staging, hopefully anyone could suggest a solution.

So I am deploying Rails 4 with Capistrano to DO droplet. I have production/staging branches on different droplets (actually I am deploying staging for the first time and can't get it working). Deployment went well, I have my app in "current" folder ready. But what I have troubles with is creating database. When I run

RAILS_ENV=production bundle exec rake db:create

I get

Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "reconnect"=>false, "database"=>"blabladb", "pool"=>5, "username"=>"root", "password"=>"pass", "host"=>"111.11.11.111"}, {:charset=>"utf8", :collation=>"utf8_unicode_ci"}

I go to production.log and it says something like

FATAL Mysql2 Error Can't connect to MySQL server on "111.11.11.111" (111)

I try to connect to mysql from console - everything goes fine. I do not know what the problem could be here.

My database.yml from current folder:

production:
adapter: mysql2
encoding: utf8
reconnect: false
database: blabladb
pool: 5
username: root
password: pass
host: 111.11.11.111

1
Where have you got that IP address for host from?Robin Fisher
Can you connect to the same MySQL instance from the console? Maybe you're connecting to the local instance instead without realizing it.tadman
@RobinFisher that is dummy IP, in real app it is IP of the dropletalv_721
@tadman sorry, I do not understand what You mean, could You give me more details?alv_721
How are you connecting via the mysql command-line tool?tadman

1 Answers

0
votes

Is there a user corresponding to that IP address in your mysql server. This is the reason why it works with localhost and not with IP address. Open your mysql server at production and check if access is granted to root at IP level.