1

I've tried looking for this online, but am having trouble finding exactly what I am looking for.

Where I work we have one server that has multiple apache setups on it, all accessed by different subdomains, about 5 total (ex: abc.domain.com, xyz.domain.com, def.domain.com).

Problem is there is one mysql server, on a different physical server we need to connect to, that only allows connection from specific hosts (so say abc.domain.com). Whenever we try to connect to it from PHP, sometimes the login will fail because the user trying to login will come up on a different hostname. (ex user is root@xyz.domain.com, when root@abc.domain.com is the only one allowed). If the page is refreshed a couple time, it will eventually end up using the right hostname to login with and work fine.

My question is, is it PHP on the local server, or MYSQL on the remote server that determines what hostname the user is logging in from.

I know the easiest solution would be to add the other subdomains to the mysql server list of accepted hosts, but I have control over the PHP server, and the MYSQL server is a different department, and it would be much easier to come up with a solution on the PHP side of things.

Thanks

  • 1
    is in the mysql server, you have to gran access for the user to allow income connections from those servers – Emilio Gort Sep 30 '13 at 17:26
  • this question will help you out http://stackoverflow.com/questions/16287559/mysql-adding-user-for-remote-access, describing how to create a user with remote access and privilegies – davidkonrad Sep 30 '13 at 17:30

1 Answers1

0

See here: How does mysql determine the hostname of its clients?. The MySQL server performs a reverse DNS lookup of the client IP. If you have multiple reverse entries, it's probably unpredictable which one will be used, which is why you see inconsistent results.

You should either remove the extra reverse DNS entries (they're not generally needed), or configure your permissions using the client IP rather than hostname.

Community
  • 1
  • 1
Barmar
  • 741,623
  • 53
  • 500
  • 612