当尝试使用带有 rails 的远程 mysql 数据库时,它会忽略 database.yml 文件中的主机参数,而是尝试连接到本地服务器名称。我已经用 XXX 和 localservername 清理了下面的信息。
下面是用于开发的 database.yml 条目:
development:
adapter: mysql2
encoding: utf8
database: temp_admin_development
username: XXX
password: XXX
host: 10.X.X.X
port: 3306
这是我们在运行 rake db:create 时遇到的错误:
rake aborted!
Mysql2::Error: Access denied for user 'XXX'@'localservername' to database 'temp_admin_development': CREATE DATABASE `temp_admin_development` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`
这是通过 irb 手动连接的尝试: Mysql2::Client.new(:host => "10.XXX", :username => "XXX")
Mysql2::Error: Access denied for user 'XXX'@'localservername' (using >password: NO)
from /home/XXX/.rvm/gems/ruby-1.9.3-p429/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect'
from /home/XXX/.rvm/gems/ruby-1.9.3-p429/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `initialize'
from (irb):2:in `new'
from (irb):2
from /home/XXX/.rvm/rubies/ruby-1.9.3-p429/bin/irb:16:in `<main>'
请注意,它正在尝试连接到本地服务器名称并忽略传递的主机参数。