简体   繁体   中英

Can't connect to remote mysql db with rails

I'm having trouble connecting to a remote mysql db with mysql2 gem.

I get this error:

Host 'my_ip' is not allowed to connect to this MySQL server

My db.yml says:

remote_development:
  adapter: mysql2
  reconnect: false
  host: host_ip
  encoding: utf8
  database: host_db
  pool: 5
  username: root
  password:

And when I try to connect via my sql or telnet I have no problems at all. I've double and triple checked the data con my yml, but can't get through this. Any idea?

Btw I'm using Rails 3.2.3, Ruby 1.9.3, and tried mysql2 v 0.2.18 and 0.3.11 ... pls HELP!

I solved this, pretty simple...

I just created a new user and password to the db with specific permissions instead of using root :)

Should have tried this from the beginning. I think this is the correct approach.

This seems to be a MySQL error message. I think the problem may be the user account that you are using. It should be set up with the 'username'@'%' format when setting it up. The percent sign means all ip addresses. You should then flush privileges on the server to make the account available.

development:

adapter: mysql2

encoding: utf8

reconnect: false

database: mystore_development

pool: 5

username: root

password:password

host: localhost

try this one surely it wil work...

更改您的host:localhost然后再试一次,它将起作用

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM