zoukankan      html  css  js  c++  java
  • mysql之grant权限说明

    mysql中给一个用户授权如select,insert,update,delete等其中的一个或者多个权限,主要使用grant命令,格式为:

    给没有用户授权

    grant 权限 on 数据库对象 to '用户'@'主机IP' identified by '密码';

    给已经存在的用户授权

    grant 权限 on 数据库对象 to '用户'@'主机IP';

    一、grant普通用户,查询,插入,更新,删除数据库中的所有表的权利。

    1、授予查看权限

    mysql> grant select on mysql.user to 'ranran'@'localhost';
    mysql> flushprivileges;

    2、授予插入权限

    mysql> grant insert on mysql.user to 'ranran'@'localhost';
    mysql> flush privileges;

     3、授予更新权限

    mysql> grant update on mysql.user to 'ranran'@'localhost';
    mysql> flush privileges;
    

    4、授予删除权限

    mysql> grant delete on mysql.user to 'ranran'@'localhost';
    mysql> flush privileges;
    

     5、查看授予的权限

    mysql> show grants for 'ranran'@'localhost';
    +----------------------------------------------------------------------------------------+
    | Grants for ranran@localhost                                                            |
    +----------------------------------------------------------------------------------------+
    | GRANT CREATE, CREATE USER ON *.* TO 'ranran'@'localhost'                               |
    | GRANT SELECT, INSERT, UPDATE, DELETE, CREATE ON `mysql`.`user` TO 'ranran'@'localhost' |
    +----------------------------------------------------------------------------------------+
    2 rows in set (0.00 sec)
    

     6、或者用一条命令插入

    mysql> grant select,insert,update,delete on *.* to 'ranran'@'localhost';
    

     

  • 相关阅读:
    考试心得 模拟18
    模拟17 题解
    模拟16 题解
    考试心得 模拟17
    模拟15 题解(waiting)
    BZOJ2653 middle 【主席树】【二分】*
    BZOJ3932 CQOI2015 任务查询系统 【主席树】
    与或 【线段树】 *
    BZOJ1014 JSOI2008 火星人prefix 【非旋转Treap】*
    网络流--最大权闭合子图 *
  • 原文地址:https://www.cnblogs.com/charon2/p/10573543.html
Copyright © 2011-2022 走看看