我只是想與mongrel服務器的rails一起使用mysql。我將服務器設置的很好,並且可以運行不需要mysql的rails應用程序,但是當我使用(例如)rails -d mysql blog創建項目並創建一些簡單的控制器時,例如Ruby腳本/生成測試,然後把這個代碼在控制器...使用Rails的mysql錯誤
class TestController < ApplicationController
def index
render :text => 'WORK'
end
end
然後當我啓動服務器,並打開了localhost:3000/test
我得到以下錯誤:
=> Booting Mongrel => Rails 2.3.5 application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server /!\ FAILSAFE /!\ Mon May 10 20:15:06 -0500 2010 Status: 500 Internal Server Error Can't connect to MySQL server on 'localhost' (10061) C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/mysql_adapter.rb:589:in 'real_connect' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/mysql_adapter.rb:589:in 'connect' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/mysql_adapter.rb:203:in 'initialize' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/mysql_adapter.rb:75:in 'new' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/mysql_adapter.rb:75:in 'mysql_connection' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_pool.rb:223:in 'send' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_pool.rb:223:in 'new_connection' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_pool.rb:245:in 'checkout_new_connection' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_pool.rb:188:in 'checkout' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_pool.rb:184:in 'loop' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_pool.rb:184:in 'checkout' C:/Ruby/lib/ruby/1.8/monitor.rb:242:in 'synchronize' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_pool.rb:183:in 'checkout' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_pool.rb:98:in 'connection' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_pool.rb:326:in 'retrieve_connection' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_specification.rb:123:in 'retrieve_connection' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_specification.rb:115:in 'connection' etc...
在瀏覽器中我得到一個'我們很抱歉,但出了點問題'
有誰知道我在做什麼錯?
Database setup: development: adapter: mysql encoding: utf8 reconnect: false database: blog_development pool: 5 username: root password: host: localhost
所以我不complpetely知道什麼是接下來的部分你問的是MySQL的,但位於
C:\wamp\bin\mysql\mysql5.1.36\bin
如果我錯過了你需要我道歉也是東西,數據庫存在和un/pw,這是正確的
Rails根本無法連接到您的數據庫。請包括你的數據庫配置,並讓我們知道你的數據庫實際在哪裏,所以我們可以看到哪個位不匹配:) – Matchu 2010-05-11 01:45:05
我編輯它與我認爲你需要幫助我,但我個人沒有看到什麼有可能匹配,所以我很可能錯過了一些東西,你的意思是數據庫在哪裏存在? – Cypher 2010-05-12 02:17:28