Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2786611
  • 博文数量: 423
  • 博客积分: 7770
  • 博客等级: 少将
  • 技术积分: 4766
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-09 11:58
个人简介

Oracle/DB2/Postgresql/Mysql/Hadoop/Greenplum/Postgres-xl/Mongodb

文章分类

全部博文(423)

文章存档

2019年(3)

2018年(6)

2017年(27)

2016年(23)

2015年(30)

2014年(16)

2013年(31)

2012年(73)

2011年(45)

2010年(14)

2009年(30)

2008年(30)

2007年(63)

2006年(32)

分类: Mysql/postgreSQL

2012-05-25 18:18:46

授以指定用户为指定数据库的管理员:
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>
 
阅读(2013) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~