2011-02-06 74 views
2

我無法爲Ruby on Rails安裝我的MySQL數據庫。設置完數據庫並確保config/database.yml文件匹配後,我正在運行下面的錯誤消息。耙db:migrate問題 -

U:\Rails\alpha>rake db:migrate --trace 
(in U:/Rails/alpha) 
** Invoke db:migrate (first_time) 
** Invoke environment (first_time) 
** Execute environment 
** Execute db:migrate 
rake aborted! 
Access denied for user 'admin'@'207-237-91-100.c3-0.avec-ubr13.nyr-avec.n 
y.cable.rcn.com' (using password: YES) 
C:/Ruby187/lib/ruby/gems/1.8/gems/mysql2-0.2.6-x86-mingw32/lib/mysql2/client.rb: 
37:in `connect' 
C:/Ruby187/lib/ruby/gems/1.8/gems/mysql2-0.2.6-x86-mingw32/lib/mysql2/client.rb: 
37:in `initialize' 
C:/Ruby187/lib/ruby/gems/1.8/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/con 
nection_adapters/mysql2_adapter.rb:14:in `new' 
C:/Ruby187/lib/ruby/gems/1.8/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/con 
nection_adapters/mysql2_adapter.rb:14:in `mysql2_connection' 
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio 
n_adapters/abstract/connection_pool.rb:230:in `send' 
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio 
n_adapters/abstract/connection_pool.rb:230:in `new_connection' 
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio 
n_adapters/abstract/connection_pool.rb:238:in `checkout_new_connection' 
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio 
n_adapters/abstract/connection_pool.rb:194:in `checkout' 
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio 
n_adapters/abstract/connection_pool.rb:190:in `loop' 
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio 
n_adapters/abstract/connection_pool.rb:190:in `checkout' 
C:/Ruby187/lib/ruby/1.8/monitor.rb:242:in `synchronize' 
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio 
n_adapters/abstract/connection_pool.rb:189:in `checkout' 
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio 
n_adapters/abstract/connection_pool.rb:96:in `connection' 
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio 
n_adapters/abstract/connection_pool.rb:318:in `retrieve_connection' 
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio 
n_adapters/abstract/connection_specification.rb:97:in `retrieve_connection' 
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/connectio 
n_adapters/abstract/connection_specification.rb:89:in `connection' 
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/migration 
.rb:486:in `initialize' 
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/migration 
.rb:433:in `new' 
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/migration 
.rb:433:in `up' 
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/migration 
.rb:415:in `migrate' 
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.0.1/lib/active_record/railties/ 
databases.rake:142 
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call' 
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute' 
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each' 
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute' 
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_cal 
l_chain' 
C:/Ruby187/lib/ruby/1.8/monitor.rb:242:in `synchronize' 
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_cal 
l_chain' 
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke' 
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task' 
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level' 
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each' 
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level' 
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_excep 
tion_handling' 
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level' 
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run' 
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_excep 
tion_handling' 
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run' 
C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31 
C:/Ruby187/bin/rake:19:in `load' 
C:/Ruby187/bin/rake:19 

我查了一下15+次的密碼,它是正確的,據我可以告訴。

database.yml文件:

development: 
    adapter: mysql2 
    encoding: utf8 
    reconnect: false 
    database: dbname 
    pool: 5 
    username: admin 
    password: pwhere 
    host: sql.domain.com 

感謝

+0

您在MySQL中運行了哪些GRANT語句?而且,數據庫是否與軌道在同一主機上,或者是不同的主機? – user510365 2011-02-06 06:38:28

回答

2

測試此方法的一種方法是從rails所在的機器的命令行連接到mysql。類似於

mysql -u admin -ppwhere -h sql.domain.com 

您可能會發現無法以這種方式連接。如果是這樣,你可能有一個GRANT問題,這可能是由於在GRANT中指定了錯誤的主機。例如,如果DB和rails駐留在同一臺機器上,mysql可能會認爲您從「localhost」連接,而不是導軌盒的DNS名稱(反之亦然)。

在您可能只需要管理用戶訪問授予的一切開始:

GRANT ALL ON *.* to 'admin'@'whereever_rails_lives' IDENTIFIED BY 'pwhere' 

mysql grant syntax

訣竅是經常得到「whereever_rails_lives的權利。

+0

我的數據庫設置在域上,並使用phpMyAdmin 3.3.7,我可以在域中成功登錄。 如圖所示,我的主機行很簡單: 主機:sql.domain.com 通過轉到sql.domain.com,phpMyAdmin讓我的配置數據庫良好。 – user605065 2011-02-06 07:36:55

-3

你的權限是不正確的。這是一個蹩腳的錯誤,因爲它確實意味着兩件事。 1)你有錯誤的密碼/用戶名組合;另外,你不能連接到MySQL,這可能嚴重意味着連接到一個寶石問題,安裝問題。 Mysql會變得挑剔!

從你的問題,我收集你對這一切都很新。我所建議的不是擔心連接到MySQL,而是從sqlite開始。您不需要全文搜索和lite不提供的其他功能!

所以,讓我們開始使用sqlite3。怎麼樣?

這是少工作。只需製作一個Rails應用程序,然後完成。然後,當你需要mysql數據庫的功能時,你可以真正知道在熟悉Rails和調試方面的錯誤。