What distinguishes a user in MySQL?
1st user:
CREATE USER 'us开发者_运维问答er5'@'';
SET PASSWORD FOR 'user5'@'' = PASSWORD('123457');
2nd user:
CREATE USER 'user5'@'%';
SET PASSWORD FOR 'user5'@'%' = PASSWORD('123456');
The part after @
specifies a host from which the user being created is allowed to connect. For example, for web applications where Web-server and MySQL server live on the same physical machine, this parameter usually set to localhost
. %
means all hosts, saying that user is allowed to connect from any machine.
Although username@hostname1
and username@hostname2
use same username, they are different users and can have different privileges.
'user5'@'' and 'user5'@'%' is the same. but the user with the host =% has a higher priority to the user with a host =''.
精彩评论