DCL语句

DCL语句

DCL语句用于控制用户对数据库对象的访问权限,主要包括Grant(授权)、Revoke(撤消)、Deny(拒绝)三种语句


  1. mysql> select database();
  2. +------------+
  3. | database() |
  4. +------------+
  5. | mysql |
  6. +------------+
  7. 1 row in set (0.00 sec)


  8. mysql> create database sakila;
  9. Query OK, 1 row affected (0.00 sec)


  10. mysql> show databases;
  11. +--------------------+
  12. | Database |
  13. +--------------------+
  14. | information_schema |
  15. | mysql |
  16. | performance_schema |
  17. | sakila |
  18. | starive |
  19. | test |
  20. +--------------------+
  21. 6 rows in set (0.04 sec)


创建一个数据库用户z1,具有对sakila数据库中所有表的select/insert权限

  1. mysql> grant select,insert on sakila.* to 'z1'@'localhost' identified by 'gao';
  2. Query OK, 0 rows affected (0.00 sec)
z1的密码已经更改为 123。

登录MySQL
  1. gaoyu@gaoyu-VirtualBox:~$ sudo mysql -u z1 -p
  2. Enter password:
  3. Welcome to the MySQL monitor. Commands end with ; or \\g.
  4. ..........
  5. ..........


收回z1的权限insert

mysql> revoke insert on sakila.* from 'z1'@'localhost';
Query OK, 0 rows affected (0.00 sec)



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

转载于:http://blog.itpub.net/26435490/viewspace-1260047/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值