我有一个远程Mysql服务器,并远程获得所有权限。从本地计算机远程登录后,这是“show grants”的输出:
+-------------------------------------------------------------------------------------------------------------+
| Grants for user@% |
+-------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'mysqluser'@'%' IDENTIFIED BY PASSWORD '*B25E737EE2274D7343BF9DCDF6CAF8DB2EAC17E1' |
+-------------------------------------------------------------------------------------------------------------+
但是,当我尝试在本地rails环境中使用此服务器时,它会说:
/home/myuser/.rvm/gems/ruby-1.9.3-p429@my_project/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in
connect': Access denied for user 'mysqluser'@'localhost' (using password: YES) (Mysql2::Error) from /home/myuser/.rvm/gems/ruby-1.9.3-p429@my_project/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in
initialize'< / p>
这是我的database.yml:
development:
adapter: mysql2
encoding: utf8
reconnect: true
username: mysqluser
password: password
hostname: 192.10.23.114
database: db_name
pool: 5
timeout: 5000
我不明白为什么Mysql认为我的用户实际上来自“localhost” 使用远程访问?你们对此有什么想法吗?非常感谢。
答案 0 :(得分:2)
hostname
的使用不正确。
应该是:
host: 192.10.23.114
答案 1 :(得分:0)
陀,
此外,您还需要确保安装了mysql2 gem。有关更多配置详细信息,请查看:http://guides.rubyonrails.org/getting_started.html#configuring-a-database