如何在MySQL中创建可以授予任何权限的用户

u3r8eeie  于 2022-12-17  发布在  Mysql
关注(0)|答案(1)|浏览(176)

我想要一个专门的有限用户在MySQL这是用来创建一个新的数据库,创建一个新的用户,并授予所有权限的新数据库的新用户。根据MySQL manual,授予任何人任何东西,你需要Alternatively, if you have the UPDATE privilege for the grant tables in the mysql system database, you can grant any account any privilege.
以下是我尝试过的特权:

GRANT CREATE, CREATE ROLE, CREATE TEMPORARY TABLES, CREATE USER, DROP ROLE, RELOAD, SHOW DATABASES ON *.* TO `admin-xxx`@`46.x.x.x` WITH GRANT OPTION;
GRANT INSERT, SELECT, UPDATE ON `mysql`.* TO `admin-xxx`@`46.x.x.x`;

我可以创建数据库和用户,但GRANT失败,并显示:

ERROR 1044 (42000): Access denied for user 'admin-xxx'@'46.x.x.x' to database 'xxx_abc'

根据手册,还需要什么才能授予权限?

编辑:

mysql> show grants;
+--------------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for admin-xxx@46.x.x.x                                                                                                                         |
+--------------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT CREATE, RELOAD, SHOW DATABASES, CREATE TEMPORARY TABLES, CREATE USER, CREATE ROLE, DROP ROLE ON *.* TO `admin-xxx`@`46.x.x.x` WITH GRANT OPTION |
| GRANT SELECT, INSERT, UPDATE ON `mysql`.* TO `admin-xxx`@`46.x.x.x`                                                                                   |
+--------------------------------------------------------------------------------------------------------------------------------------------------------+
bihw5rsg

bihw5rsg1#

您可以在授权后添加

FLUSH PRIVILEGES;

相关问题