部署后Rails 4无法连接到mysql

时间:2021-09-23 03:00:49

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

所以我正在使用Capistrano将Rails 4部署到DO droplet。我在不同的水滴上有生产/分期分支(实际上我是第一次部署分期并且无法使其工作)。部署顺利,我的应用程序在“当前”文件夹准备就绪。但我遇到的麻烦是创建数据库。当我跑

RAILS_ENV=production bundle exec rake db:create

RAILS_ENV =生产包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"}

无法为{“adapter”=>“mysql2”,“encoding”=>“utf8”,“reconnect”=> false,“database”=>“blabladb”,“pool”=> 5,“用户名”创建数据库“=>”root“,”password“=>”pass“,”host“=>”111.11.11.111“},{:charset =>”utf8“,:collat​​ion =>”utf8_unicode_ci“}

I go to production.log and it says something like

我去了production.log并且说了类似的东西

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

FATAL Mysql2错误无法连接到“111.11.11.111”(111)上的MySQL服务器

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

我尝试从控制台连接到mysql - 一切都很顺利。我不知道这里可能出现什么问题。

My database.yml from current folder:

我当前文件夹中的database.yml:

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

生产:适配器:mysql2编码:utf8重新连接:false数据库:blabladb池:5用户名:root密码:传递主机:111.11.11.111

1 个解决方案

#1


0  

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.

在mysql服务器中是否有与该IP地址对应的用户。这就是为什么它适用于localhost而不是IP地址的原因。在生产时打开您的mysql服务器,并检查是否在IP级别授予root访问权限。

#1


0  

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.

在mysql服务器中是否有与该IP地址对应的用户。这就是为什么它适用于localhost而不是IP地址的原因。在生产时打开您的mysql服务器,并检查是否在IP级别授予root访问权限。