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-04-26MySQL查出时间比实际晚8小时的解决方案
- 2024-04-01JPA不识别MySQL的枚举类型
- 2024-03-30mysql数据库表卡死解决方法
- 2024-03-15MySQL多数据源笔记5-ShardingJDBC实战
- 2024-03-11natural join mysql
- 2024-03-11关于VS2017,VS2015 中利用 EF使用Mysql 不显示数据源问题解决方案
- 2024-02-26mysql 阿里云xb后缀备份文件恢复-icode9专业技术文章分享
- 2024-02-22docker mysql 5.7
- 2024-02-18从 20 多套 MySQL 到 1 套 TiDB丨骏伯网络综合运营管理平台应用实践
- 2024-02-07mysql 外键索引入门介绍,为什么工作中很少有人使用?