mysql 创建数据库及用户并授权

Posted on 2022-09-09 10:43  zkx4213  阅读(54)  评论(0编辑  收藏  举报
参考mysql 函数赋权 mysql赋予全部权限_mob6454cc75107c的技术博客_51CTO博客

-- 创建testDb数据库
create schema testDb default character set utf8 collate utf8_general_ci;

-- 创建testUser用户并设置密码
create user 'testUser'@'%' identified by '123456';

-- 授予查询、更新、删除、插入权限
grant select,update,delete,insert on `testDb`.* to 'testUser'@'%';
-- 授予数据库开发人员,创建表、索引、视图、存储过程、函数等权限
grant create on `testDb`.* to 'testUser'@'%';
grant alter on `testDb`.* to 'testUser'@'%';
grant drop on `testDb`.* to 'testUser'@'%';

-- 授予操作mysql外键权限
grant references on `testDb`.* to 'testUser'@'%';

-- 授予操作mysql临时表权限
grant create temporary tables on `testDb`.* to 'testUser'@'%';

-- 授予操作mysql索引权限
grant index on `testDb`.* to 'testUser'@'%';

-- 授予操作mysql视图、查看视图源代码权限
grant create view on `testDb`.* to 'testUser'@'%';
grant show view on `testDb`.* to 'testUser'@'%';

-- 授予操作mysql存储过程、函数权限
grant create routine on `testDb`.* to 'testUser'@'%';
grant alter routine on `testDb`.* to 'testUser'@'%';
grant execute on `testDb`.* to 'testUser'@'%';
flush privileges;

 







 

Copyright © 2024 zkx4213
Powered by .NET 9.0 on Kubernetes