lysanderK 2020-04-19
all为所有权限
订单数据库.*表示订单数据中的所有表
system_dbowner 为用户名
%表示所有ip地址
usercode1为密码
这句grant命令执行后如果数据库中没有对应的角色会自动创建
grant all on 订单数据库.* to ‘system_dbowner‘@‘%‘ identified by ‘usercode1‘;
grant select,insert,update,delete on 订单数据库.* to ‘datarecorder1‘@‘%‘ identified by ‘usercode1‘; grant select,insert,update,delete on 订单数据库.* to ‘datarecorder2‘@‘%‘ identified by ‘usercode1‘;
--授予订单数据库所有表的查询权限 grant select on 订单数据库.* to ‘order_1‘@‘%‘ identified by ‘usercode1‘; grant select on 订单数据库.* to ‘order_2‘@‘%‘ identified by ‘usercode1‘; -- 授予订单数据库订单表和订货项目表的增删改权限 grant insert,update,delete on 订单数据库.订单 to ‘order_1‘@‘%‘ identified by ‘usercode1‘; grant insert,update,delete on 订单数据库.订单 to ‘order_2‘@‘%‘ identified by ‘usercode1‘; grant insert,update,delete on 订单数据库.订货项目 to ‘order_1‘@‘%‘ identified by ‘usercode1‘; grant insert,update,delete on 订单数据库.订货项目 to ‘order_2‘@‘%‘ identified by ‘usercode1‘;
-- 赋予登陆权限 grant usage on *.* to ‘customer_2‘@‘%‘ identified by ‘usercode1‘; grant usage on *.* to ‘customer_1‘@‘%‘ identified by ‘usercode1‘; -- 赋予对订单数据库查询权限 grant select on 订单数据库.* to ‘customer_2‘@‘%‘ identified by ‘usercode1‘; grant select on 订单数据库.* to ‘customer_1‘@‘%‘ identified by ‘usercode1‘; -- 赋予对代理商和客户表的增删改权限 grant insert,update,delete on 订单数据库.客户 to ‘customer_2‘@‘%‘ identified by ‘usercode1‘; grant insert,update,delete on 订单数据库.客户 to ‘customer_1‘@‘%‘ identified by ‘usercode1‘; grant insert,update,delete on 订单数据库.代理商 to ‘customer_2‘@‘%‘ identified by ‘usercode1‘; grant insert,update,delete on 订单数据库.代理商 to ‘customer_1‘@‘%‘ identified by ‘usercode1‘;