mysql查看用户名的方法:首先进入mysql并启动数据库;然后连接到数据库;最后输入“select host,user from mysql.user;”命令查看用户名以及信息即可。
我们在使用mysql的时候,有时候需要来查看当前用户。本篇文章将和大家讲述mysql怎么查看用户名,感兴趣的朋友可以了解一下。
启动数据库:
[root@server ~]# mysqld_safe &[1] 3289[root@server ~]# 130913 08:19:58 mysqld_safe logging to '/usr/local/mysql/data/server.gao.err'.130913 08:19:58 mysqld_safe starting mysqld daemon with databases from /usr/local/mysql/data
连接到数据库:
[root@server ~]# mysql -uroot -penter password: welcome to the mysql monitor. commands end with ; or \g.your mysql connection id is 1server version: 5.6.13 mysql community server (gpl)copyright (c) 2000, 2013, oracle and/or its affiliates. all rights reserved.oracle is a registered trademark of oracle corporation and/or itsaffiliates. other names may be trademarks of their respectiveowners.type 'help;' or '\h' for help. type '\c' to clear the current input statement.mysql>
查看数据库列表:
mysql> show databases;+--------------------+| database |+--------------------+| information_schema || mysql || performance_schema || test |+--------------------+rows in set (0.00 sec)mysql>
查看用户状态:
mysql> use mysql;reading table information for completion of table and column namesyou can turn off this feature to get a quicker startup with -adatabase changedmysql> select host,user from mysql.user;+------------+------+| host | user |+------------+------+| 127.0.0.1 | root || ::1 | root || localhost | || localhost | root || server.gao | || server.gao | root |+------------+------+rows in set (0.00 sec)mysql>
以上就是mysql怎么查看用户名?的详细内容。