MySQL下查看用户、数据库

    Read

命令行下查看用户、数据库:
[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 -ASourceByrd's Weblog-https://note.t4x.org/database/show-database-tables/

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)SourceByrd's Weblog-https://note.t4x.org/database/show-database-tables/

mysql> use gbk
Database changed
mysql> select database();
+------------+
| database() |
+------------+
| gbk |
+------------+
1 row in set (0.00 sec)SourceByrd's Weblog-https://note.t4x.org/database/show-database-tables/

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)SourceByrd's Weblog-https://note.t4x.org/database/show-database-tables/

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;
[/mysql]
申明:本文由BYRD原创(基于Mysql5.6.16),未经许可禁止转载!SourceByrd's Weblog-https://note.t4x.org/database/show-database-tables/ SourceByrd's Weblog-https://note.t4x.org/database/show-database-tables/

申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!
Byrd
  • by Published on May 11, 2014
  • 原文链接:https://note.t4x.org/database/show-database-tables/
匿名

Comment

Anonymous

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: