Under what scenarios would one want to connect to a host other than localhost? What I mean is when:
mysql_connect('localhost', 'root', 'root');
I provide ‘localhost’ as the first argument without ever stopping to think what purpose it serves. I guess the opposite would be remote host, but when would you actually use it?
localhostis a hostname that refers to the local machine.Therefore, you pass that to connect to a server running on the local machine.
If you want to connect to a MySQL server running on a different machine, you would pass that machine’s domain name or IP address instead of
localhost.