1

I know that you can access a database from a domain name with a user like this user@example.com but will this user also be able to access the database if they are trying to connect via another page on that domain i.e. example.com/page?

I am asking this as I am trying to connect from a domain name that will be establishing connections from different pages and sub folders i.e. example.com/admin/page, will setting it up with just example.com as the ending will all variables of that domain be accepted from the database connection?

  • 1
    Your question does not make sense to me. Application connects to MySQL server, not "webpage", "domain" or "url". Some application (probably a web server) serves those domains and returns the pages and it (or a scripting language run by it - PHP/ASP...) is the one connecting to mysql. – jkavalik Oct 9 '15 at 11:57
  • when I say "I know that you can access a database from a domain name with a user like this user@example.com" I mean that you can create a remote mysql user that can access from a domain name, the statement in mysql would look like GRANT ALL PRIVILEGES ON *.* TO user@example.com IDENTIFIED BY 'password' WITH GRANT OPTION; what im asking is, can this user access from all variables of example.com? – LewisJWright Oct 9 '15 at 12:03
  • ah.. user@example.com is in the form <username>@<hostname>, hostname is a dns name of some computer (what its IP address reverse-translates to), it does not have any folders, it might have subdomains, but these would translate to a different IP probably, or at least only one host should be specified for the reverse lookup – jkavalik Oct 9 '15 at 12:07
1

From your example:

GRANT ALL PRIVILEGES ON *.* TO user@example.com IDENTIFIED BY 'password' WITH GRANT OPTION; 

That reference to example.com has little to do with the web site example.com and particularly not with users of that site or pages on that site.

Machines with IP addresses are often reachable by hostnames. Given a hostname, DNS provides you with a way to look up the IP address(es) associated with that hostname. Reverse DNS provides the opposite -- given an IP address, look up a hostname that can be used to reach that IP address.

MySQL allows user accounts to be associated with an IP address or range (e.g. 'user'@'10.1.1.1' or 'user'@'10.1.%', meaning 10.1..) but it also allows the IP address matching the rule to be derived from reverse DNS. For 'user'@'example.com' to work, the IP address of the machine connecting to the MySQL Server must reverse-lookup to example.com, and a forward lookup of example.com must then return the connecting machine's IP address.

As you hopefully see, this operating at a layer where the page a user on the example.com web server is completely meaningless, and if other web sites were hosted on that same server, the permission for other sites hosted on that server to access the MySQL Server would not be any different. The hostname on in a mysql user account serves only to identify the machine making the incoming connection. MySQL has no idea why that machine might be connecting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.