命令行下查看用戶、數據庫:
mysql> use gbk #進入gbk數據庫
Database changed
mysql> show tables; #查看gbk數據庫的所有表
Empty set (0.00 sec)
mysql> use ultrax;
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> show tables;
mysql> show tables from ultrax; #查看ultrax數據庫的數據表[mysql> show tables in ultrax;]
+-----------------------------------+
| Tables_in_ultrax |
+-----------------------------------+
| pre_common_admincp_cmenu |
| pre_common_admincp_group |
…………………………………省略部分內容………………………………
| pre_ucenter_tags |
| pre_ucenter_vars |
+-----------------------------------+
293 rows in set (0.01 sec)
mysql> use gbk
Database changed
mysql> select database();
+------------+
| database() |
+------------+
| gbk |
+------------+
1 row in set (0.00 sec)
mysql> select user,host from mysql.user; #查看用戶、主機
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1 |
| | lamp |
| root | lamp |
| | localhost |
| root | localhost |
+------+-----------+
6 rows in set (0.06 sec)
mysql> drop user ''@'localhost'; #刪除用戶名為空,主機名為localhost
mysql> drop user ''@'lamp'; #刪除主機名為lamp,用戶名為空
Query OK, 0 rows affected (0.09 sec)
mysql> select user,host from mysql.user; #查看是否刪除成功
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1 |
| | lamp |
| root | lamp |
| root | localhost |
+------+-----------+
5 rows in set (0.00 sec)
mysql> delete from mysql.user where user='' and host='lamp'; #如果無法刪除的可以采用類似此種的方法進行刪除
mysql> flush privileges;