Rails 3.2.13应用程序在共享主机Mysql更新后失败

时间:2015-01-30 07:29:00

标签: mysql ruby-on-rails ruby ruby-on-rails-3

我在Justhost服务器上有两个Rails 3.2.13应用程序。

最近他们将Mysql更新为Mysql2,之后我遇到了错误:

Ruby (Rack) application could not be started

具体:

Error message:
(Mysql2::Error)

我的设置

bundle show mysql转向:/home3/ecotec11/rails_apps/ecotechno/vendor/bundle/ruby/1.9.3/gems/mysql2-0.3.16

database.yml

production:
  adapter: mysql2
  encoding: utf8
  reconnect: true
  database: database_name
  pool: 5
  username: username
  password: password
 # socket: /tmp/mysql.sock

的Gemfile

gem 'mysql2'
当我联系支持时,Bassicaly说他们无法帮助我。

完全回溯错误:

0   /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/mysql2-0.3.16/lib/mysql2/client.rb  24  in `initialize_ext'
1   /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/mysql2-0.3.16/lib/mysql2/client.rb  24  in `initialize'
2   /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/mysql2_adapter.rb 16  in `new'
3   /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/mysql2_adapter.rb 16  in `mysql2_connection'
4   /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb   315 in `new_connection'
5   /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb   325 in `checkout_new_connection'
6   /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb   247 in `block (2 levels) in checkout'
7   /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb   242 in `loop'
8   /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb   242 in `block in checkout'
9   /usr/lib64/ruby/1.9.3/monitor.rb    211 in `mon_synchronize'
10  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb   239 in `checkout'
11  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb   102 in `block in connection'
12  /usr/lib64/ruby/1.9.3/monitor.rb    211 in `mon_synchronize'
13  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb   101 in `connection'
14  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb   410 in `retrieve_connection'
15  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_specification.rb  171 in `retrieve_connection'
16  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_specification.rb  145 in `connection'
17  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/model_schema.rb   310 in `clear_cache!'
18  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/railtie.rb    103 in `block (2 levels) in '
19  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activesupport-3.2.16/lib/active_support/callbacks.rb    418 in `_run__4470304995410275411__prepare__777669663684257344__callbacks'
20  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activesupport-3.2.16/lib/active_support/callbacks.rb    405 in `__run_callback'
21  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activesupport-3.2.16/lib/active_support/callbacks.rb    385 in `_run_prepare_callbacks'
22  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activesupport-3.2.16/lib/active_support/callbacks.rb    81  in `run_callbacks'
23  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/actionpack-3.2.16/lib/action_dispatch/middleware/reloader.rb    74  in `prepare!'
24  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/actionpack-3.2.16/lib/action_dispatch/middleware/reloader.rb    48  in `prepare!'
25  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/railties-3.2.16/lib/rails/application/finisher.rb   47  in `block in '
26  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/railties-3.2.16/lib/rails/initializable.rb  30  in `instance_exec'
27  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/railties-3.2.16/lib/rails/initializable.rb  30  in `run'
28  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/railties-3.2.16/lib/rails/initializable.rb  55  in `block in run_initializers'
29  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/railties-3.2.16/lib/rails/initializable.rb  54  in `each'
30  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/railties-3.2.16/lib/rails/initializable.rb  54  in `run_initializers'
31  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/railties-3.2.16/lib/rails/application.rb    136 in `initialize!'
32  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/railties-3.2.16/lib/rails/railtie/configurable.rb   30  in `method_missing'
33  /home3/ecotec11/rails_apps/technorent/config/environment.rb 10  in `'
34  config.ru   3   in `require'
35  config.ru   3   in `block in
'
36  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/rack-1.4.5/lib/rack/builder.rb  51  in `instance_eval'
37  /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/rack-1.4.5/lib/rack/builder.rb  51  in `initialize'
38  config.ru   1   in `new'
39  config.ru   1   in `
'
40  /etc/httpd/modules/passenger/lib/phusion_passenger/rack/application_spawner.rb  225 in `eval'
41  /etc/httpd/modules/passenger/lib/phusion_passenger/rack/application_spawner.rb  225 in `load_rack_app'
42  /etc/httpd/modules/passenger/lib/phusion_passenger/rack/application_spawner.rb  157 in `block in initialize_server'
43  /etc/httpd/modules/passenger/lib/phusion_passenger/utils.rb 563 in `report_app_init_status'
44  /etc/httpd/modules/passenger/lib/phusion_passenger/rack/application_spawner.rb  154 in `initialize_server'
45  /etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server.rb   204 in `start_synchronously'
46  /etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server.rb   180 in `start'
47  /etc/httpd/modules/passenger/lib/phusion_passenger/rack/application_spawner.rb  129 in `start'
48  /etc/httpd/modules/passenger/lib/phusion_passenger/spawn_manager.rb 253 in `block (2 levels) in spawn_rack_application'
49  /etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server_collection.rb    132 in `lookup_or_add'
50  /etc/httpd/modules/passenger/lib/phusion_passenger/spawn_manager.rb 246 in `block in spawn_rack_application'
51  /etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server_collection.rb    82  in `block in synchronize'
52      prelude>    10:in `synchronize'
53  /etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server_collection.rb    79  in `synchronize'
54  /etc/httpd/modules/passenger/lib/phusion_passenger/spawn_manager.rb 244 in `spawn_rack_application'
55  /etc/httpd/modules/passenger/lib/phusion_passenger/spawn_manager.rb 137 in `spawn_application'
56  /etc/httpd/modules/passenger/lib/phusion_passenger/spawn_manager.rb 275 in `handle_spawn_application'
57  /etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server.rb   357 in `server_main_loop'
58  /etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server.rb   206 in `start_synchronously'
59  /etc/httpd/modules/passenger/helper-scripts/passenger-spawn-server  99  in `

在应用程序日志中:

Connecting to database specified by database.yml
Connecting to database specified by database.yml
Connecting to database specified by database.yml
Connecting to database specified by database.yml
Connecting to database specified by database.yml
Connecting to database specified by database.yml
Connecting to database specified by database.yml

我检查了数据库是否存在。拥有密码的用户有效。

我测试了控制台的工作原理。是的有效。

rails console production

我能够创建新记录并更新现有记录!

这让我想到了什么是错的呢?如果仅用于webservice数据库不起作用?

那么这个问题来自哪里?

任何提示都会很棒。 感谢

1 个答案:

答案 0 :(得分:2)

我通过恢复到mysql并将端口号3306添加到我的database.yml轻松解决了这个问题 *记录我的应用程序是在Bluehost上的共享主机。

以前的database.yml:

development:
adapter: mysql2
database: my_db
encoding: utf8
username: my_username
password: my_password
host: localhost
reconnect: true

当前database.yml:

development:
adapter: mysql
database: my_db
encoding: utf8
username: my_username
password: my_password
host: 127.0.0.1
reconnect: true
socket: mysql
port: 3306