Remote access from domain and other pages on that domain
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.