我正在尝试使用我的Ruby on Rails应用程序从Dreamhost访问远程数据库,本地或远程没有运气。
当我尝试rake db:migrate
时,我一直收到此错误:
Mysql2::Error: Access denied for user 'USERNAME'@'108-233-86-201.lightspeed.sntcca.sbcglobal.net' (using password: YES)
我检查过:
这是我的 database.yml 在我测试时的样子:
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: "yoshirtdb"
pool: 5
username: "USERNAME"
password: "XXXXXX"
host: "phpadmin.domain.com"
port: 3306
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: "mysql_production"
pool: 5
host: "localhost"
port: 3306
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: "yoshirtdb"
pool: 5
username: "root"
password: "root"
host: "localhost"
port: 8889
socket: "/Applications/MAMP/tmp/mysql/mysql.sock"
连接到我的本地数据库工作。所以我现在将它们保存在生产下。请忽略它。此外,出于安全考虑,我更改了用户名/密码和域名。
非常感谢任何正确方向的帮助。
修改
另外,当我运行rake db:create
时,我得到的唯一消息是:
Couldn't create database for {"adapter"=>"mysql2", "database"=>"yoshirtdb", "username"=>"USERNAME", "password"="XXXXXX">"", "host"=>"phpadmin.domain.com"}
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "reconnect"=>false, "database"=>"mysql_production", "pool"=>5, "host"=>"localhost", "port"=>3306}, {:charset=>"utf8", :collation=>"utf8_unicode_ci"}
(If you set the charset manually, make sure you have a matching collation)