ITPub博客

首页 > 数据库 > MySQL > DCL语句

DCL语句

原创 MySQL 作者:starive 时间:2014-08-29 11:48:05 0 删除 编辑

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

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



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

上一篇: MySQL DML语句
下一篇: MySQL帮助使用
请登录后发表评论 登录
全部评论

注册时间:2014-01-18

  • 博文量
    143
  • 访问量
    530075