Mysql下查看用户、数据库的例子
发布:smiling 来源: PHP粉丝网 添加日期:2015-04-17 17:13:10 浏览: 评论:0
在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;
Tags: Mysql查看用户 Mysql数据库
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)