Creating new MySQL user... password and privileges not sticking
Solution 1:
You have an anonymose user for localhost and that anonymous user don't have any password.
It is necessary to have both (
%
andlocalhost
) accounts for yourmyuser
to be able to connect from anywhere asmyuser
. Without the localhost account, theanonymous user
account forlocalhost
that is created bymysql_install_db
would take precedence whenmyuser
connects from thelocalhost
. As a result,myuser
would be treated as ananonymous user
. The reason for this is that the anonymous-user account has a more specific Host column value than themyuser'@'%'
account and thus comes earlier in the user table sort order.
About sort order:
The server uses sorting rules that order rows with the most-specific Host values first. Literal host names and IP addresses are the most specific. (The specificity of a literal IP address is not affected by whether it has a netmask, so for example
192.168.1.13
and192.168.1.0/255.255.255.0
are considered equally specific.) The pattern'%'
means"any host"
and is least specific. The empty string''
also means"any host"
but sorts after'%'
. Rows with the same Host value are ordered with the most-specific User values first (a blank User value means"any user"
and is least specific).
So mysql
is considering your myuser
as an anonymous user
and since the anonymous user
for localhost
don't have any password, it is able to login without password.
To resolve your issue, you just need to create a localhost
user for your myuser
with password