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 (% and localhost) accounts for your myuser to be able to connect from anywhere as myuser. Without the localhost account, the anonymous user account for localhost that is created by mysql_install_db would take precedence when myuser connects from the localhost. As a result, myuser would be treated as an anonymous user. The reason for this is that the anonymous-user account has a more specific Host column value than the myuser'@'%' 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 and 192.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