Phusion Passenger 无法访问 mysql

Phusion Passenger 无法访问 mysql

我可以从终端连接到数据库。

Rails 控制台也连接良好,我可以返回对象、对其进行修改并从那里执行任何操作。因此 database.yml 一定没问题

但由于某种原因,乘客就是无法连接......

我错过了什么?

错误

Ruby on Rails application could not be started

There appears to be a database problem.
Your config/database.yml may not be written correctly. Please check it and fix any     errors.
Your database schema may be out of date or nonexistant. Please run rake db:migrate to   ensure that the database schema is up-to-date.
The database server may not be running. Please check whether it's running, and start it    if  it isn't.

Error message:
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)   (Mysql::Error)

Exception class:
Mysql::Error

谢谢

答案1

以下两种情况之一:

  • 乘客运行的用户没有访问套接字对象的权限,

或者,

  • 数据库未运行。

由于您可以从终端进行连接和查询,因此这可能是权限问题。乘客以哪个用户身份运行,您从哪里获得权限ls -l /var/lib/mysql/

答案2

确保您的 Rails 应用程序实际上以您希望的模式运行:

grep RAILS_ENV config/environment.rb
grep RailsEnv /path/to/Apache/config

和:

egrep '^production|^development' -A6 config/database.yml

相关内容