我创建了一个MySQL数据库" gefdb"和用户" testuser" 我完成的用户创建:
> CREATE USER 'testuser'@'localhost' IDENTIFIED BY '********';
> CREATE USER 'testuser'@'%' IDENTIFIED BY '********';
我登录为" root"为了授予" gefdb"的所有权限用户" 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'
我试图验证一些事情:
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 |
+----------------+----------------+
我不知道为什么我不能将gefdb上的PRIVILEGES设置为testuser。任何的想法? 问题是我用" testuser"
登录后无法使用gefdbmysql -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)
似乎用户" testuser"无法访问" gefdb"但我不知道自己做错了什么。