Page 1 of 1

MySQL Hostname

PostPosted: 27. September 2010 19:33
by richlocus
Hello:
I am new with MySQL, and wanted to clarify the hostname parameter to log in.
For example, on my fresh install of XAMPP, I can shell out and log into the MySQL console as follows:
# mysql -h localhost -u root

To create a new account that can only browse, I can use this format:
GRANT SELECT on testdb.* TO 'joesmith'@'coolwebsite.com' IDENTIFIED BY 'joespassword';

So, does MySQL check the hostname for validity. Otherwise, what use is it?

It seems like Joe could go to any computer on any host and login as follows:

#mysql -h coolwebsite -u joesmith -p joespassword;

Could someone explain the significance of including a host name?

Thanks,
Rich Locus

Re: MySQL Hostname

PostPosted: 27. September 2010 20:04
by JonB
Basically its this:

For most purposes of a website, the 'localhost' is an adequate arrangement. This is because the database 'work' is happening on the same physical sever that is also hosting the website. So for the website user - he is impersonated by the WebApplication Server - that user is seen as being an authenticated application (user) running on 'localhost'.

But - in several situations this just won't work. First, for larger database applications (or ones that 'serve' more than one application server) - you may want to have a dedicated database server. To communicate with it, you will need a 'hostname' (usually in the form of a URI i.e. database1.mydomain.net). The second no-quite-so-apparent case is if you wish to use some database tools or do development work on another workstation (either locally or over the internet) those tools (like the MySQL Workbench design tool) or another PHP application being designed will have to know how to 'find' the right MySQL server - and that means either an IP address or a hostname (the left section of a FQDN including the hostname segment) and, in soem cases - the MySQL Port number in use.

Oh yeah - and Joe COULD do that - but that the point of security isn't it? There's the hostname locale restriction that is set in MySQL - you can specify what hostnames or IP's folks (and their appy little friends) can come in from. ''%" - means wildcard.

http://dev.mysql.com/doc/refman/5.0/en/dns.html

OK?

:mrgreen:

Re: MySQL Hostname

PostPosted: 27. September 2010 20:13
by richlocus
Jon:
Thanks... that makes it clearer to me.... 8)