DCL语句
DCL语句用于控制用户对数据库对象的访问权限,主要包括Grant(授权)、Revoke(撤消)、Deny(拒绝)三种语句- mysql> select database();
- +------------+
- | database() |
- +------------+
- | mysql |
- +------------+
- 1 row in set (0.00 sec)
-
-
- mysql> create database sakila;
- Query OK, 1 row affected (0.00 sec)
-
-
- mysql> show databases;
- +--------------------+
- | Database |
- +--------------------+
- | information_schema |
- | mysql |
- | performance_schema |
- | sakila |
- | starive |
- | test |
- +--------------------+
- 6 rows in set (0.04 sec)
创建一个数据库用户z1,具有对sakila数据库中所有表的select/insert权限
- mysql> grant select,insert on sakila.* to 'z1'@'localhost' identified by 'gao';
- Query OK, 0 rows affected (0.00 sec)
登录MySQL
- gaoyu@gaoyu-VirtualBox:~$ sudo mysql -u z1 -p
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \\g.
- ..........
- ..........
收回z1的权限insert
mysql> revoke insert on sakila.* from 'z1'@'localhost';
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26435490/viewspace-1260047/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26435490/viewspace-1260047/