开发者

2 user in MySQL, hosts = "%" and '" (empty)

开发者 https://www.devze.com 2023-02-07 12:50 出处:网络
What distinguishes a user in MySQL? 1st user: CREATE USER \'us开发者_运维问答er5\'@\'\'; SET PASSWORD FOR \'user5\'@\'\' = PASSWORD(\'123457\');

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

0

精彩评论

暂无评论...
验证码 换一张
取 消