在mysql中要查看用户名与数据库我们可以在mysql命令模式下直接使用相关的命令就可以查了,具体的小编就为各位介绍一下吧.
命令行下查看用户、数据库:
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 ; #查看是否删除成功 + ------+-----------+ --phpfensi.com | 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;
查看更多关于Mysql下查看用户、数据库的例子的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did3929