MySQL Hostname

Problems with the Windows version of XAMPP, questions, comments, and anything related.

MySQL Hostname

Postby richlocus » 27. September 2010 19:33

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'@'' 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?

Rich Locus
Posts: 3
Joined: 25. September 2010 20:28

Re: MySQL Hostname

Postby JonB » 27. September 2010 20:04

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. 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.


User avatar
AF Moderator
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: MySQL Hostname

Postby richlocus » 27. September 2010 20:13

Thanks... that makes it clearer to me.... 8)
Posts: 3
Joined: 25. September 2010 20:28

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 57 guests