MySQL创建具有权限的用户自行删除

时间:2013-04-29 01:08:48

标签: mysql grant sql-drop

我需要帮助如何创建一个有可能删除自己的新用户......

CREATE USER 'AdminPS'@'localhost' IDENTIFIED BY PASSWORD  '*CC3DA61A4716581A6A62EE83E5F4119D8C0B5D23';

GRANT ALL ON Database.* TO 'AdminPS'@'localhost';
GRANT DROP USER 'AdminPS'@'localhost' TO 'AdminPS'@'localhost';

3 个答案:

答案 0 :(得分:1)

您只需要替换最后一行:

CREATE USER 'AdminPS@localhost' IDENTIFIED BY PASSWORD '*CC3DA61A4716581A6A62EE83E5F4119D8C0B5D23';
GRANT ALL ON Database.* TO 'AdminPS@localhost';
GRANT CREATE USER ON *.* TO 'AdminPS@localhost';

答案 1 :(得分:0)

正如GRANT Syntax所述:

  

表13.1。 GRANT和REVOKE允许的权限

+-----------------+-------------------------------------------+
|    Privilege    |                  Meaning                  |
+-----------------+-------------------------------------------+
:                 :                                           :
| CREATE USER     | Enable use of CREATE USER, DROP USER,     |
|                 | RENAME USER, and REVOKE ALL PRIVILEGES    |
:                 :                                           :
+-----------------+-------------------------------------------+
:                 :                                           :
| DROP            | Enable databases, tables, and views to be |
|                 | dropped                                   |
:                 :                                           :
+-----------------+-------------------------------------------+

因此,您需要授予CREATE USER权限,而不是DROP

答案 2 :(得分:0)

您需要使用WITH GRANT OPTION创建用户。

e.g.: GRANT ALL ON Database.* TO 'AdminPS'@'localhost' WITH GRANT OPTION;