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

What distinguishes the user from MySQL?

1st user:

CREATE USER 'user5'@''; SET PASSWORD FOR 'user5'@'' = PASSWORD('123457'); 

2nd user:

 CREATE USER 'user5'@'%'; SET PASSWORD FOR 'user5'@'%' = PASSWORD('123456'); 
+4
source share
2 answers

'user5' @ '' and 'user5' @ '%' are the same. but the user with host =% has a higher priority for the user with host = ''.

+2
source

The part after @ indicates the host from which user access is allowed. For example, for web applications where the web server server and MySQL are running on the same physical machine, this parameter is usually set to localhost . % means all hosts that say that the user is allowed to connect from any machine.

Although username@hostname1 and username@hostname2 use the same username, they are different users and may have different privileges.

+3
source

Source: https://habr.com/ru/post/1337502/


All Articles