问题一:
用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
阅读(5494) | 评论(0) | 转发(2) |