Use of hostname
is incorrect.
It should read:
host: 192.10.23.114
Question
I have a remote Mysql server, and got all privileges remotely. Here is the output of "show grants" after I logged in remotely, from local computer:
+-------------------------------------------------------------------------------------------------------------+
| Grants for user@% |
+-------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'mysqluser'@'%' IDENTIFIED BY PASSWORD '*B25E737EE2274D7343BF9DCDF6CAF8DB2EAC17E1' |
+-------------------------------------------------------------------------------------------------------------+
However, when I try to use this server in a local rails environment, it says this:
/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'
Here is my 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
What I don't understand is why Mysql thinks my user is from "localhost" when I was actually using a remote access? Do you guys have any idea on this? Thanks a lot.
Solution
Use of hostname
is incorrect.
It should read:
host: 192.10.23.114
OTHER TIPS
Tuo,
Additionally, you're going to want to make sure you have the mysql2 gem installed. For more configuration details, please check: http://guides.rubyonrails.org/getting_started.html#configuring-a-database