Mysql下查看用户、数据库的例子
2019/10/10/17:32:36 阅读:2059 来源:谷歌SEO算法 标签:
发外链
在mysql中要查看用户名与数据库我们可以在mysql命令模式下直接使用相关的命令就可以查了,具体的小编就为各位介绍一下吧.
命令行下查看用户、数据库:
- mysql>usegbk#进入gbk数据库
- Databasechanged
- mysql>showtables;#查看gbk数据库的所有表
- Emptyset(0.00sec)
- mysql>useultrax;
- Readingtableinformationforcompletionoftableandcolumnnames
- Youcanturnoffthisfeaturetogetaquickerstartupwith-A
- Databasechanged
- mysql>showtables;
- mysql>showtablesfromultrax;#查看ultrax数据库的数据表[mysql>showtablesinultrax;]
- +-----------------------------------+
- |Tables_in_ultrax|
- +-----------------------------------+
- |pre_common_admincp_cmenu|
- |pre_common_admincp_group|
- …………………………………省略部分内容………………………………
- |pre_ucenter_tags|
- |pre_ucenter_vars|
- +-----------------------------------+
- 293rowsinset(0.01sec)
- mysql>usegbk
- Databasechanged
- mysql>selectdatabase();
- +------------+
- |database()|
- +------------+
- |gbk|
- +------------+
- 1rowinset(0.00sec)
- mysql>selectuser,hostfrommysql.user;#查看用户、主机
- +------+-----------+
- |user|host|
- +------+-----------+
- |root|127.0.0.1|
- |root|::1|
- ||lamp|
- |root|lamp|
- ||localhost|
- |root|localhost|
- +------+-----------+
- 6rowsinset(0.06sec)
- mysql>dropuser''@'localhost';#删除用户名为空,主机名为localhost
- mysql>dropuser''@'lamp';#删除主机名为lamp,用户名为空
- QueryOK,0rowsaffected(0.09sec)
- mysql>selectuser,hostfrommysql.user;#查看是否删除成功
- +------+-----------+--phpfensi.com
- |user|host|
- +------+-----------+
- |root|127.0.0.1|
- |root|::1|
- ||lamp|
- |root|lamp|
- |root|localhost|
- +------+-----------+
- 5rowsinset(0.00sec)
mysql> delete from mysql.user where user='' and host='lamp';#如果无法删除的可以采用类似此种的方法进行删除.
mysql> flush privileges;
热门评论