Using this command
GRANT ALL PRIVILEGES ON *.* to \'brian\'@\'%\' identified by \'password\';
I try to login with:
mysql -
The mysql docs have this to say: (from http://dev.mysql.com/doc/refman/5.1/en/adding-users.html):
Two of the accounts have a user name of
monty
and a password ofsome_pass
. Both accounts are superuser accounts with full privileges to do anything. The'monty'@'localhost'
account can be used only when connecting from the local host. The'monty'@'%'
account uses the'%'
wildcard for the host part, so it can be used to connect from any host.It is necessary to have both accounts for
monty
to be able to connect from anywhere asmonty
. Without the localhost account, the anonymous-user account for localhost that is created bymysql_install_db
would take precedence when monty connects from the local host. As a result,monty
would be treated as an anonymous user. The reason for this is that the anonymous-user account has a more specificHost
column value than the'monty'@'%'
account and thus comes earlier in the user table sort order.
With this in mind I would recommend you create a 'brian'@'localhost'
user with the same privileges.
You forgot the quotes around brian in your grant statement. Try it like this:
GRANT ALL PRIVILEGES ON *.* to 'brian'@'%' identified by 'password';
You probably have this perpetual MySQL problem where one of the default users in the user table is '' @ localhost
, which winds up denying all localhost
users later in the table. What I would do is mysqldump
the mysql
database and look for this entry in the User
table; if found, delete it and flush privileges.
For more details see https://dev.mysql.com/doc/refman/5.5/en/connection-access.html.
It is a common misconception to think that, for a given user name, all rows that explicitly name that user are used first when the server attempts to find a match for the connection. This is not true. The preceding example illustrates this, where a connection from h1.example.net by jeffrey is first matched not by the row containing 'jeffrey' as the User column value, but by the row with no user name. As a result, jeffrey is authenticated as an anonymous user, even though he specified a user name when connecting.
Similar problem occurred for me even after verifying i haven't entered a wrong password, i couldn't login. Below two steps solved my problem.
None of the solutions provided here worked. After loads of error and trial I realised that I had special characters in the password. Changing password without special characters solved the issue
Change to native password using this command:
ALTER USER 'username'@'hostname' IDENTIFIED WITH mysql_native_password BY 'password';