ITPub博客

首页 > 数据库 > MySQL > MySQL-授权用户管理数据库

MySQL-授权用户管理数据库

原创 MySQL 作者:13545163656 时间:2018-05-03 14:52:51 0 删除 编辑
一、grant 普通 DBA 管理某个 MySQL 数据库的权限。
    grant all privileges on dbname to dba@'localhost'
    其中,关键字 “privileges” 可以省略。
二、grant 高级 DBA 管理 MySQL 中所有数据库的权限。
    grant all on *.* to dba@'localhost'
三. grant 作用在表中的列上:
    grant select(id, se, rank) on testdb.apache_log to dba@localhost;
四、查看 MySQL 用户权限
    查看当前用户(自己)权限:
    show grants;
    查看其他 MySQL 用户权限:
    show grants for dba@localhost;
五、撤销已经赋予给 MySQL 用户权限的权限。
    revoke 跟 grant 的语法差不多,只需要把关键字 “to” 换成 “from” 即可:
    grant  all on *.* to   dba@localhost;
    revoke all on *.* from dba@localhost;

测试: 创建数据库用户 ,授权某个库权限
 

create user 'bj'@'%' identified by 'bj';
flush privileges;
grant SELECT ,INSERT,update ,delete,create ,drop on  bjsjjh.* to 'bj'@'%' identified by 'bj' ;
flush privileges;

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31441024/viewspace-2153749/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2017-03-05

  • 博文量
    70
  • 访问量
    97995