mysql授权
2022/6/2 2:21:17
本文主要是介绍mysql授权,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
grant语法
GRANT priv_type [(column_list)] [, priv_type [(column_list)]] ... ON [object_type] priv_level TO user_or_role [, user_or_role] ... [WITH GRANT OPTION] [AS user [WITH ROLE DEFAULT | NONE | ALL | ALL EXCEPT role [, role ] ... | role [, role ] ... ] ] } GRANT PROXY ON user_or_role TO user_or_role [, user_or_role] ... [WITH GRANT OPTION] GRANT role [, role] ... TO user_or_role [, user_or_role] ... [WITH ADMIN OPTION] object_type: { TABLE | FUNCTION | PROCEDURE } priv_level: { * | *.* | db_name.* | db_name.tbl_name | tbl_name | db_name.routine_name } user_or_role: { user (see Section 6.2.4, “Specifying Account Names”) | role (see Section 6.2.5, “Specifying Role Names”) }
基本语法
grant [权限] on [数据库名].[表名] to 'user_name'@'host_name' ....;
例子
授权db的所有权限给指定的账户 GRANT ALL ON db.* to 'user_name'@'localhost'; 给指定的用户授予角色 GRANT 'role1','role2' to 'user_name'@'localhost','user_name2'@'localhost'; 授权db数据库的查询权限给指定用户 GRANT SELECT ON db.* to 'user_name'@'localhost'; 给用户授权所有数据库的权限 GRANT ALL ON *.* to 'user_name'@'localhost';
查看权限
show privileges;
这篇关于mysql授权的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-16MySQL资料:新手入门教程
- 2024-11-16MySQL资料:新手入门教程
- 2024-11-15MySQL教程:初学者必备的MySQL数据库入门指南
- 2024-11-15MySQL教程:初学者必看的MySQL入门指南
- 2024-11-04部署MySQL集群项目实战:新手入门教程
- 2024-11-04如何部署MySQL集群资料:新手入门指南
- 2024-11-02MySQL集群项目实战:新手入门指南
- 2024-11-02初学者指南:部署MySQL集群资料
- 2024-11-01部署MySQL集群教程:新手入门指南
- 2024-11-01如何部署MySQL集群:新手入门教程