授以指定用户为指定数据库的管理员:
GRANT ALL PRIVILEGES ON tank. * TO IDENTIFIED BY 'tank' WITH GRANT OPTION;
[root@localhost ~]# /usr/local/mysql-5.1.46/bin/mysql -utank8 -ptank
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 26
Server version: 5.1.62-log Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| tank |
| test |
+--------------------+
3 rows in set (0.00 sec)
mysql>
mysql> show tables;
+----------------+
| Tables_in_tank |
+----------------+
| b |
| t |
+----------------+
2 rows in set (0.00 sec)
mysql> select * from b;
+------+------+
| id | name |
+------+------+
| 1 | k |
| 1 | k |
| 1 | k |
| 1 | k |
| 1 | k |
| 1 | k |
| 1 | k |
+------+------+
7 rows in set (0.00 sec)
mysql> select * from t;
+------+------+
| id | name |
+------+------+
| 1 | t |
| 1 | t |
| 1 | t |
| 1 | t |
+------+------+
4 rows in set (0.00 sec)
mysql>
GRANT usage ON tank. * TO IDENTIFIED BY 'bb';建立bb用户只有连接权限,
grant select on tank.b TO ; 只授以tank数据库中的b表,给bb这个用户select权限。
[root@localhost ~]# /usr/local/mysql-5.1.46/bin/mysql -ubb -pbb
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 28
Server version: 5.1.62-log Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| tank |
| test |
+--------------------+
3 rows in set (0.00 sec)
mysql> use tank
Database changed
mysql> show tables;
+----------------+
| Tables_in_tank |
+----------------+
| b |
+----------------+
1 row in set (0.00 sec)
mysql> select * from b;
+------+------+
| id | name |
+------+------+
| 1 | k |
| 1 | k |
| 1 | k |
| 1 | k |
| 1 | k |
| 1 | k |
| 1 | k |
+------+------+
7 rows in set (0.00 sec)
mysql>
阅读(2017) | 评论(0) | 转发(0) |