• MYSQL 创建用户并授权


    MYSQL 创建用户并授权

    版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/van38686061/article/details/75666439

    通过CREATE USER命令进行创建用户
    CREATE USER 'username@host' [IDENTIFIED BY 'PASSWORD'] 其中密码是可选项;
    例子:CREATE USER 'john@192.168.189.71' IDENTIFIED BY "123";
    说明:该方法创建出来的用户只有连接数据库的权限,需要后续继续授权;

    =========================================

    查询、插入、更新、删除 数据库中所有表数据的权利。
    grant select on testdb.* to common_user@'%'
    grant insert on testdb.* to common_user@'%'
    grant update on testdb.* to common_user@'%'
    grant delete on testdb.* to common_user@'%'
    或者,用一条 MySQL 命令来替代:
    grant select, insert, update, delete on testdb.* to common_user@'%'

    创建表、索引、视图、存储过程、函数等权限。
    grant create on testdb.* to developer@'192.168.0.%';
    grant alter on testdb.* to developer@'192.168.0.%';
    grant drop on testdb.* to developer@'192.168.0.%';

    操作外键权限。
    grant references on testdb.* to developer@'192.168.0.%';

    操作临时表权限。
    grant create temporary tables on testdb.* to developer@'192.168.0.%';

    操作索引权限。
    grant index on testdb.* to developer@'192.168.0.%';
     
    操作视图、查看视图源代码权限
    grant create view on testdb.* to developer@'192.168.0.%';
    grant show view on testdb.* to developer@'192.168.0.%';
     

    操作存储过程、函数 权限
    grant create routine on testdb.* to developer@'192.168.0.%'; -- now, can show procedure status
    grant alter routine on testdb.* to developer@'192.168.0.%'; -- now, you can drop a procedure
    grant execute on testdb.* to developer@'192.168.0.%';
     
    管理数据库的权限。
    grant all privileges on testdb to dba@'localhost'
    其中,关键字 “privileges” 可以省略


    管理所有数据库的权限。
    grant all on *.* to dba@'localhost'

    查看当前用户(自己)权限:
    show grants;
     
    查看其他用户权限:
    show grants for dba@localhost;

    撤销已经赋予给用户权限的权限。
    revoke 跟 grant 的语法差不多,只需要把关键字 “to” 换成 “from” 即可:
    grant all on *.* to dba@localhost;

    revoke all on *.* from dba@localhost;

    请记得刷新系统权限表;

    flush privileges;

  • 相关阅读:
    关于CDH集群spark的三种安装方式简述
    CDH高可用hadoop集群性能配置
    CDH集群的时间同步--简要配置要求
    CDH集群的配置优化须知
    MySQL在Linux系统环境的安装和无主机登录配置
    配置文件my.cnf---配置信息注释大全
    Scrapy项目
    Scrapy项目
    Scrapy项目
    Scrapy项目
  • 原文地址:https://www.cnblogs.com/waj2018/p/9947544.html
Copyright © 2020-2023  润新知