Connecting to MySQL through the command-line client as "root", I am trying to create a MySQL user with the following commands:
mysql> create user 'myuser'@'%' identified by 'mypass';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on MY_DATABASE.* to 'myuser'@'%' identified by 'mypass';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
The user is created, but its password and privileges are not "sticking". When I try to login using the password, I get an error:
~$ mysql -u myuser -p
Enter password:
ERROR 1045 (28000): Access denied for user 'myuser'@'localhost' (using password: YES)
However, I CAN login by simply pressing [enter] without a password:
~$ mysql -u myuser -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 95
Server version: 5.5.28-0ubuntu0.12.04.3 (Ubuntu)
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
Still, the user cannot see any tables... so not only did the password fail to persist, but the privileges that I set were lost too.
Does anyone know what I'm missing here? Thanks!
UPDATE: Posting contents from the mysql.user table, as requested in the comments:
mysql> select User, Host, Password from mysql.user;
+------------------+---------------------+-------------------------------------------+
| User | Host | Password |
+------------------+---------------------+-------------------------------------------+
| root | localhost | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
| root | 127.0.0.1 | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
| root | ::1 | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
| | localhost | |
| debian-sys-maint | localhost | *817684763DD0B095B4703EC55053DAB57A2D9F4F |
| phpmyadmin | localhost | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
| myuser | % | *C5250F20FB991AA969917726DE6547D425DB3234 |
+------------------+---------------------+-------------------------------------------+
select User,Host,Password from mysql.user;
in your question.