Score:0

mysql user@% can access from localhost

ca flag

I was always told that "%" means every host except localhost.

However I have created a user4@"%" and I can connect to from localhost.

screenshot

So now I am a bit confused regarding this. Can anyone clarify this for me, please?

ua flag
Is there another entry for `user4`? Or maybe `"%"@"%"? Switch to the sister forum dba.stackexchange.com if you don't get satisfaction in serverfault.
ptor avatar
ca flag
Nope. That's the only one.
Score:2
ar flag

I was always told that "%" means every host except localhost.

This is plain wrong.

% is a wildcard. It matches 0 or more of any character:

SQL pattern matching enables you to use _ to match any single character and % to match an arbitrary number of characters (including zero characters)

Thus % in the hostname field matches any host, including localhost.

ptor avatar
ca flag
Thanks for the information.
ua flag
But, I think that user@host is treated specially.
ptor avatar
ca flag
In the documentation says that @"localhost" is treated differently on UNIX systems because they use a UNIX socket as protocol for local connections. However it doesn't say what's the difference. According to my teacher, user1@"%" should not be allowed to connect to the server locally but my tests prove otherwise.
vidarlo avatar
ar flag
The client defaults to attempting socket communication for localhost. That doesn't change mysql's wildcard handling however. Your tests are however entirely right, and matches the documentation re. wildcards - and your teacher is wrong.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.