Mysql下查看使用者、資料庫的例子

來源:互聯網
上載者:User

命令列下查看使用者、資料庫:

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;    #查看是否刪除成功
+------+-----------+
| 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;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.