Chinaunix首页 | 论坛 | 博客
  • 博客访问: 286673
  • 博文数量: 134
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 118
  • 用 户 组: 普通用户
  • 注册时间: 2013-08-01 14:02
文章分类

全部博文(134)

文章存档

2015年(2)

2014年(4)

2013年(128)

分类: Mysql/postgreSQL

2013-11-12 18:14:14

原文地址:Mysql删除用户信息问题 作者:丫叩酱


问题一:
       用grant创建一个用户zeros,并给它授,在mysql数据库中的user表中和
 
information_schema数据库中的USER_PRIVILEGES表中,能够查看到用户zeros的信息。
 
现在想删除用户zeros的信息,怎么办???
 
 
解决问题一:
 
 #1 使用root登录mysql:
 
     mysql无密码的:[root@...]# mysql -u root
 
     msyql有密码的:[root@...]# mysql -u root -p
 
     输入密码:
 
     mysql>
 
 
 
 #2 创建和授权用户:
  
     mysql> grant all on  zeros.*  to 
  identified  by 
 
'zeros';
  
     Query OK, 0 rows affected (0.02 sec)
 
 

 #3 查看用户zeros信息:
 
  #查看mysql数据库中的user表:
 
  mysql> use mysql;
 
  mysql> select host, user, password  from  user;
 
  +---------------+-------+------------------+
  | host          | user  | password         |
  +---------------+-------+------------------+
  | localhost     | root  |                  |
  | 127.0.0.1     | root  |                  |
  | localhost     |       |                  | 
  | 192.168.2.100 | zeros | 676dfad16ab72df9 |
  | 192.168.2.114 | zeros | 676dfad16ab72df9 | 
  +---------------+-------+------------------+
  4 rows in set (0.00 sec)
 
 
  #查看information_schema数据库中的USER_PRIVILEGES表:
 
  mysql> use information_schema;
 
  Reading table information for completion of table and column names
  You can turn off this feature to get a quicker startup with -A
  Database changed
 
  mysql> select * from USER_PRIVILEGES;
+-------------------------+---------------+-----------------------+--------------+
| GRANTEE                 | TABLE_CATALOG | PRIVILEGE_TYPE        |IS_GRANTABLE  |
+-------------------------+---------------+-----------------------+--------------+
  ................................................................................
| | NULL          | USAGE                 | NO           |
|
| NULL          | USAGE                 | NO           | |           | NULL          | USAGE                 | NO           |
+-------------------------+---------------+-----------------------+--------------+
 
 

 #4 删除用户zeros信息:
 
  mysql> drop user ;
 
  Query OK, 0 rows affected (0.00 sec)
 

  #查看mysql数据库中的user表:
 
  mysql> use mysql;
 
  mysql> select host, user, password  from  user;
 
  +---------------+-------+------------------+
  | host          | user  | password         |
  +---------------+-------+------------------+
  | localhost     | root  |                  |
  | 127.0.0.1     | root  |                  |
  | localhost     |       |                  | 
  | 192.168.2.100 | zeros | 676dfad16ab72df9 |
  +---------------+-------+------------------+
  4 rows in set (0.00 sec)
 
  mysql> use information_schema;
 
  Reading table information for completion of table and column names
  You can turn off this feature to get a quicker startup with -A
  Database changed
 
 
  #查看information_schema数据库中的USER_PRIVILEGES表:
 
  mysql> select * from USER_PRIVILEGES;
 
+-------------------------+---------------+-----------------------+--------------+
| GRANTEE                 | TABLE_CATALOG | PRIVILEGE_TYPE        | IS_GRANTABLE |
+-------------------------+---------------+-----------------------+--------------+
....................................................................................
| | NULL          | USAGE                 | NO           |
|           | NULL          | USAGE                 | NO           | +-------------------------+---------------+-----------------------+--------------+
 
 
注意:
 
DROP的用法:

    DROP USER语句用于删除一个或多个MySQL账户。要想移除账户,应使用Drop USER user语
 
句。
  
    DROP USER user [, user2] ...
  
    使用与GRANT或REVOKE相同的格式为每个账户命名;例如,。 账户
 
名称的用户和主机部分与用户表记录的User和Host列值相对应。
 
    注意:要使用DROP USER,您必须拥有mysql数据库的全局Create USER权限或Delete权限。
 
 
 
使用DROP USER,您可以取消一个账户和其权限,操作如下:
 
    DROP USER ;
 
    该语句可以删除来自所有授权表的帐户权限记录。
 
    drop user
 
    drop user
 
阅读(458) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~