Thursday, June 12, 2008

Mysql - Associate a username with Mupltiple hosts

Mysql stores user account information in user table of mysql database.
In Mysql, same username can be assoicated with Multiple hosts. You can create multiple accounts with same username. you can use differnt password, and previlages for each account.

e.g we can create following two accounts with same username maulin

maulin@localhost - This account can be used only when connecting with localhost.
maulin@% - This account can be used only when connecting from any other host.

To determine which account applies, the server uses the username value in conjunction with the name of the host from which you connect. This means that there can be different accounts with the same username, which can be used for connections from different hosts. So make sure you are using correct combination of username & hosts for connecting database, otherwise you will get connection error.

0 Java Junction comments: