gpt4 book ai didi

mysql - rake db :migrate - 问题

转载 作者:太空宇宙 更新时间:2023-11-03 16:59:32 26 4
gpt4 key购买 nike

我无法为 Ruby on Rails 设置我的 MySQL 数据库。设置数据库并确保 config/database.yml 文件匹配后,我遇到了以下错误消息。

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 次以上,据我所知密码是正确的。

数据库.yml文件:

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

谢谢

最佳答案

测试这个的一种方法是从 Rails 所在的机器的命令行连接到 mysql。有点像

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

您可能会发现您也无法通过这种方式进行连接。如果是这样,您可能遇到了 GRANT 问题,这可能是由于在 GRANT 中指定了错误的主机。例如,如果数据库和 rails 位于同一台机器上,mysql 可能认为您是从“本地主机”连接的,而不是 rails 框的 DNS 名称(反之亦然)。

一开始您可能只想授予管理员用户访问所有内容的权限:

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

mysql grant syntax

诀窍通常是让“wherever_rails_lives”正确。

关于mysql - rake db :migrate - 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4911976/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com