简体   繁体   English

Rails从WEBrick连接到MySQL,但没有从Passenger连接到MySQL

[英]Rails connects to MySQL from WEBrick but not from Passenger

I just created a new Rails 4 app with MySql as follows: 我刚刚使用MySql创建了一个新的Rails 4应用程序,如下所示:

rails new mysqltest -d mysql

And modified the database.yml with the right credentials. 并使用正确的凭据修改了database.yml。

I generated a sample contoller and updated the routes for root route. 我生成了一个样本控制器,并将路由更新为根路由。

When I start using WEBrick in production, 当我开始在生产中使用WEBrick时,

rails s -e production

The site works. 该站点正常工作。 I see the index page. 我看到索引页面。

When I start using Passenger without 3000 port, I see the following error: 当我开始使用没有3000端口的Passenger时,我看到以下错误:

database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)

Passsenger is running in Production environment. Passsenger在生产环境中运行。

My database.yml 我的database.yml

# MySQL.  Versions 4.1 and 5.0 are recommended.
#
# Install the MYSQL driver
#   gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
#   gem 'mysql2'
#
# And be sure to use new-style password hashing:
#   http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
  adapter: mysql2
  encoding: utf8
  database: sample
  pool: 5
  username: sample
  password: sample
  socket: /var/run/mysqld/mysqld.sock

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: mysql2
  encoding: utf8
  database: sample
  pool: 5
  username: sample
  password: sample
  socket: /var/run/mysqld/mysqld.sock

production:
  adapter: mysql2
  encoding: utf8
  database: sample
  pool: 5
  username: sample
  password: sample
  socket: /var/run/mysqld/mysqld.sock

The case I used in database.yml file and the apache config file were different. 我在database.yml文件和apache配置文件中使用的情况不同。

Both should be same. 两者应该相同。 eg. 例如。 production . production

In apache config, I gave as Production . 在apache config中,我给定为Production After changing it to production it worked. 将其更改为production后,它可以正常工作。

Source - https://groups.google.com/forum/#!topic/phusion-passenger/Kr-R0gSw6i8 来源-https: //groups.google.com/forum/#!topic/ phusion- passenger/ Kr- R0gSw6i8

Did you create your local production database? 您是否创建了本地生产数据库?

rake db:create:all
RAILS_ENV=production bundle exec rake db:migrate

Is your database.yml file setup properly to use a production database? 是否正确设置了database.yml文件以使用生产数据库?

Do you have a mysql gem in your gem file. 您的gem文件中是否有mysql gem。

Common problems. 常见问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM