I have created a MySQL database "gefdb" and a user "testuser" The user creation I have done with:
> CREATE USER 'testuser'@'localhost' IDENTIFIED BY '********';
> CREATE USER 'testuser'@'%' IDENTIFIED BY '********';
I login as "root" in order to grant all privileges on "gefdb" to user "testuser".
mysql -h localhost -u root -p
mysql> GRANT ALL PRIVILEGES ON `gefdb`.* TO 'testuser'@'localhost' WITH GRANT OPTION;
ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'gefdb'
I tried to verify a few things:
mysql> use mysql;
mysql> SELECT user,host FROM db WHERE db='gefdb';
+----------+-----------+
| user | host |
+----------+-----------+
| testuser | % |
| testuser | localhost |
+----------+-----------+
mysql> SELECT host,user,Grant_priv,Super_priv FROM mysql.user;
+-------------------+------------+------------+------------+
| host | user | Grant_priv | Super_priv |
+-------------------+------------+------------+------------+
| localhost | root | Y | Y |
mysql> select user(), current_user();
+----------------+----------------+
| user() | current_user() |
+----------------+----------------+
| root@localhost | root@localhost |
+----------------+----------------+
I dont know why I cannot set the PRIVILEGES on gefdb to testuser. Any idea? The problem is that I cannot use the gefdb after I login with "testuser":
mysql -h localhost -u testuser -p
mysql> use gefdb;
#1044 - Access denied for user 'testuser'@'localhost' to database 'gefdb'
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.00 sec)
It seems that the user "testuser" does not have access to the "gefdb" but I don't know what I did wrong.