0

I tried to grant user for database at database.com from a domain but it failed. Only the domain's IP works. (example.com is having IP 1.1.1.1)

For example:

GRANT super ON *.* TO 'user'@'1.1.1.1' IDENTIFIED BY 'password';

The above works fine. I can access the database remotely.

GRANT super ON *.* TO 'user'@'example.com' IDENTIFIED BY 'password';

This failed!

When I try to use PHP script to connect from example.com to database.com, it says:

mysql_connect('database.com', 'user', 'password');

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'user'@'1.1.1.1' (using password: YES)

Any idea why giving privilege to user base on domain 'user'@'example.com' doesn't work?

neobie
  • 2,847
  • 5
  • 27
  • 31
  • `Any idea why giving privilege to user base on domain 'user'@'example.com' doesn't work?` No, because you did not specify what failed. What's the error message? Can your database server actually resolve the host name (by DNS or hosts file)? And btw, are you sure you want to grant `super`? You might want to read about the different privileges before granting randomly some rights which sound good but in fact you don't know what they do. (sorry, if this is a false assumption) – fancyPants Apr 25 '14 at 10:15

1 Answers1

1

As per my understanding your server administrator has restricted to host name, you can check in your server config file (my.cnf) if "skip-name-resolve" is updated.

Even you should call based on IP in your application instead of name but if still you want to do it then comment "skip-name-resolve" in your config file.

Zafar Malik
  • 6,734
  • 2
  • 19
  • 30