2012-05-03 46 views
8

Mọi thứ hoạt động tốt trên máy tính xách tay phát triển OS X của tôi.Bàn điều khiển Rails sản xuất sẽ không bắt đầu

Triển khai ứng dụng để sản xuất và nó chạy và hiển thị dữ liệu như mong đợi.

Tuy nhiên, khi tôi cố gắng chạy Rails console trên máy chủ sản xuất, tôi nhận được một lỗi ...

$ rails console -e production 
/opt/deployed_rails_apps/con_app_rails_3/shared/bundle/ruby/1.9.1/gems/mysql2-0.3.11/lib/mysql2/client.rb:44: 
    in `connect': Can't connect to local MySQL server through socket 
     '/tmp/mysql.sock' (2) (Mysql2::Error) 

    from /opt/deployed_rails_apps/con_app_rails_3/shared/bundle/ruby/1.9.1/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `initialize' 
    from /opt/deployed_rails_apps/con_app_rails_3/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new' 

tôi đã cố gắng loại bỏ socket: /tmp/mysql.sock từ database.yml - kết quả tương tự.

Mặc dù ứng dụng chạy, tôi cũng cần có thể truy cập vào bảng điều khiển trong quá trình sản xuất để thực hiện một số tác vụ nhất định.

Tôi có thể kết nối với máy chủ MySQL bằng ứng dụng dòng lệnh MySQL.


ruby ​​1.9.3p125

Rails 3.2.2

mysql2 đá quý 0.3.11

MySQL server: 5.1.61

máy chủ sản xuất: Linux 2.6.32- 220.4.2.el6.x86_64

database.yml

development: 
    adapter: mysql2 
    encoding: utf8 
    reconnect: false 
    database: con_app_rails_3_development 
    pool: 5 
    username: root 
    password: 
    socket: /tmp/mysql.sock 

test: 
    adapter: mysql2 
    encoding: utf8 
    reconnect: false 
    database: con_app_rails_3_test 
    pool: 5 
    username: root 
    password: 
    socket: /tmp/mysql.sock 

production: 
    adapter: mysql2 
    encoding: utf8 
    reconnect: false 
    host: dbhost 
    database: con_app_rails_3_production 
    pool: 5 
    username: xxxx 
    password: xxxx 
    socket: /tmp/mysql.sock 

Trả lời

35

Giải quyết.

Tất cả tôi cần làm là ...

$ RAILS_ENV=production bundle exec rails console 
+0

Tôi không cần phải thực hiện 'bó exec', nhưng chỉ định' RAILS_ENV = production' FIRST trên dòng lệnh là quan trọng. –

8

Một cách khác để làm điều này:

./script/rails console production

1

tôi giải quyết với chạy:

RAILS_ENV=production bundle exec rails c 

thêm chi tiết về link

Các vấn đề liên quan