gpt4 book ai didi

mysql - 未配置生产数据库

转载 作者:行者123 更新时间:2023-11-29 00:23:04 25 4
gpt4 key购买 nike

在我的服务器上,mysql 正在运行。

$ pgrep mysql
28636

Rails 控制台命令有效。

anand@app-Staging:~/public_html/app_staging/current$ rails console staging  
Loading staging environment (Rails 3.0.19)
irb(main):001:0>

但是当我从浏览器访问该应用程序时,乘客抛出此错误。

Your application's database configuration file might be written incorrectly. Please check it and fix any errors.
The database server may not be running. Please check whether it's running, and start it if it isn't.

Error message:
production database is not configured (ActiveRecord::AdapterNotSpecified)
Exception class:
ActiveRecord::AdapterNotSpecified
Application root:
/home/anand/public_html/app_staging/current

这是我的apache配置

anand@app-Staging:/etc/apache2/sites-enabled$ cat app_staging 
<VirtualHost *:80>

ServerName myappstaging.org
ServerAlias *.myappstaging.org

DocumentRoot /home/anand/public_html/app_staging/current/public

RailsEnv staging

RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^OPTIONS
RewriteRule .* - [R=405,L]

XSendFile on

</VirtualHost>

这是我的config/database.yml

staging:
adapter: mysql2
encoding: utf8
database: app_staging
username: root
password: xxxxxx
host: localhost

我已经重新启动了 mysql 并尝试了。还重新启动了apache。我检查了 apache 配置文件中的乘客配置行。

没有任何作用。我错过了什么吗?请帮忙。

最佳答案

我应该指定 Rails 环境,例如 RackEnv staging for Rails versions >= 3.x

此配置解决了问题。

anand@app-Staging:/etc/apache2/sites-enabled$ cat app_staging 
<VirtualHost *:80>

ServerName myappstaging.org
ServerAlias *.myappstaging.org

DocumentRoot /home/anand/public_html/app_staging/current/public

RackEnv staging

RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^OPTIONS
RewriteRule .* - [R=405,L]

XSendFile on

</VirtualHost>

关于mysql - 未配置生产数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20351976/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com