capistrano 部署:用户“root”@“localhost”访问被拒绝(使用密码:YES)(Mysql::Error)

发布于 2024-09-08 02:17:49 字数 570 浏览 8 评论 0原文

我尝试在生产服务器上部署 ror 应用程序,然后收到此错误:

Access denied for user 'root'@'localhost' (using password: YES) (Mysql::Error)

但是当我运行命令时:

rake db:migrate RAILS_ENV=production

它通过了。我还从命令行连接到 mysql:

mysql -u root -p 

它成功了,我可以看到所有表都已创建。

我在一个分支上工作,在我的deploy.rb中我已经设置了分支:

set :branch 'myBranch'

在apache2配置文件中,我也设置了rails_env:

<VirtualHost *:80>
  ServerName daemon.com
  DocumentRoot /home/hy/work/log/current/public/
  RailsEnv production
</VirtualHost>

请帮忙,谢谢!

I tried to deploy ror application on production server then got this error:

Access denied for user 'root'@'localhost' (using password: YES) (Mysql::Error)

but when i ran command:

rake db:migrate RAILS_ENV=production

it passed. I also connect to mysql from command line:

mysql -u root -p 

it got through, and i can see all the tables are created.

i m working on a branch , in my deploy.rb i already set the branch:

set :branch 'myBranch'

and in apache2 configuration file, i set rails_env too:

<VirtualHost *:80>
  ServerName daemon.com
  DocumentRoot /home/hy/work/log/current/public/
  RailsEnv production
</VirtualHost>

Please help, thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挖个坑埋了你 2024-09-15 02:17:49

您可能已经经历过这个,但我建议您仔细检查您的 config/environments/development.yml 是否包含有效的凭据并已推送到存储库中。

您提到您已尝试在服务器上手动进行迁移。您是否从当前部署的应用程序所在的同一目录运行迁移?

(/home/hy/work/log/current)

You might've already been through this, but I'd suggest you double check that your config/environments/production.yml contains valid credentials and is pushed into the repository.

You mentioned you have tried to do the migration manually on the server. Did you run the migration from the very same directory, where your current deployed app lies ?

(/home/hy/work/log/current)

梨涡少年 2024-09-15 02:17:49

我知道这已经很旧了,但是您需要做的是在deploy.rb 文件中设置default_env 并设置环境变量。

像这样的东西:

set :default_env, { 
  'var1' => 'value1',
  'var2' => 'value2'
}

这适用于 Capistrano 3。希望这能帮助任何遇到这个问题的人。

I know this is old, but what you need to do is to set default_env in your deploy.rb file and set environment variables.

Something like this:

set :default_env, { 
  'var1' => 'value1',
  'var2' => 'value2'
}

This will work for Capistrano 3. Hope this will help anyone stumbling upon this question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文