MySQL查询创建用户并授予权限
要创建用户并授予许可,语法如下:
create database yourDatabaseName DEFAULT CHARACTER SET utf8;create user `yourUserName` identified by yourPassword;
GRANT SELECT ON yourDatabaseName .* TO `yourUserName`;
GRANT INSERT ON yourDatabaseName .* TO `yourUserName`;
GRANT UPDATE ON yourDatabaseName .* TO `yourUserName`;
GRANT DELETE ON yourDatabaseName .* TO `yourUserName`;
GRANT EXECUTE ON yourDatabaseName .* TO `yourUserName`;
这是创建用户并授予权限的查询-
create database demo_app DEFAULT CHARACTER SET utf8;create user `John_123` identified by '123456';
GRANT SELECT ON demo.* TO `John_123`;
GRANT INSERT ON demo.* TO `John_123`;
GRANT UPDATE ON demo.* TO `John_123`;
GRANT DELETE ON demo.* TO `John_123`;
GRANT EXECUTE ON demo.* TO `John_123`;
让我们显示上述用户的所有授权:
show grants for `John_123`;
这将产生以下输出-
+-----------------------------------------------------------------------------+| Grants for John_123@% |
+-----------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `John_123`@`%` |
| GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON `demo`.* TO `John_123`@`%` |
+-----------------------------------------------------------------------------+
2 rows in set (0.00 sec)
以上是 MySQL查询创建用户并授予权限 的全部内容, 来源链接: utcz.com/z/322545.html