MySQL to view the user, database examples

Source: Internet
Author: User

View users, databases at the command line:

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 the 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          |
... ... ....... ....... ....... ....... ..... ... Omit part of the content ....... ....... ...... ...... .....
| 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; #查看用户, Host
+------+-----------+
| 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 ';    #删除用户名为空, host name is localhost
mysql> drop user ' @ ' lamp ';     #删除主机名为lamp, the user name is empty
Query OK, 0 rows affected (0.09 sec)
Mysql> select User,host from mysql.us er;    #查看是否删除成功
+------+-----------+
| user | host      |
+------ +-----------+
| root | 127.0.0.1 |
| root |::1       |
|      | lamp      |
| root | lamp      |
| root | localhost |
+------+-----------+
5 rows in Set (0.00 sec)
Mysql> deletes from Mysql.user where user= ' and host= ' lamp ';     #如果无法删除的可以采用类似此种的方法进行删除
mysql> flush privileges;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.