MySQL Creating user rookie mistakes
I created a user ‘monty’ in a MySQL DB using the following command
CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
Then tried to connect to it from the local computer:
mysql -u monty -password=some_pass
It never worked… I spent an hour trying to figure it out, the answer was on the page I was reading.
It is necessary to have both accounts for
montyto be able to connect from anywhere asmonty. Without thelocalhostaccount, the anonymous-user account forlocalhostthat is created by mysql_install_db would take precedence whenmontyconnects from the local host. As a result,montywould be treated as an anonymous user. The reason for this is that the anonymous-user account has a more specificHostcolumn value than the'monty'@'%'account and thus comes earlier in theusertable sort order. (usertable sorting is discussed inSection 5.4.4, “Access Control, Stage 1: Connection Verification”.)
Not happy with myself right now =/