-- 创建应用管理用户app_admin:
create user app_admin identified by <passwd>;
-- 对应用管理用户授权:
grant ALTER,ALTER ROUTINE,CREATE,
CREATE VIEW,CREATE ROUTINE,CREATE USER,
CREATE TEMPORARY TABLES,DELETE,DROP,EVENT,
EXECUTE,INDEX,INSERT,LOCK TABLES,PROCESS,RELOAD,
REFERENCES,REPLICATION SLAVE,REPLICATION CLIENT
,SELECT,SHOW VIEW,TRIGGER,UPDATE
on *.*
to app_admin WITH GRANT OPTION;
-- 用应用管理用户app_admin连接,进行创建各个数据库,并进行授权:
-- 创建数据库和每个库testdb<n>对应的用户app_rw<n>
create database testdb2 character set utf8mb4;
create user app_usr2 identified by <passwd>;
--授权
grant
ALTER,ALTER ROUTINE,CREATE,CREATE TEMPORARY TABLES,
CREATE VIEW,CREATE ROUTINE,DELETE,DROP,EVENT,EXECUTE,
INSERT,INDEX,LOCK TABLES,REFERENCES,
SELECT,SHOW VIEW,TRIGGER,UPDATE
on testdb2.*
to app_usr2;
grant PROCESS,REPLICATION SLAVE,REPLICATION CLIENT on *.* to app_usr2;