版權聲明:本文為部落客原創文章,未經部落客允許不得轉載。 https://blog.csdn.net/qq_34173549/article/details/80871834
1:show databases;
檢視所有的資料庫,等同于select schema_name from information_schema.schemata\G。\G 替換;,以縱向報表的形式輸出結果,有利于閱讀。
2. status 檢視mysql資料庫的運作狀态
3. use 指令選擇資料庫 例如 use information_schema,當使用此指令後
select schema_name from information_schema.schemata\G,可以為
select schema_name from schemata\G
4. 檢視資料庫中的表
show tables
同樣也可以在information_schema中檢視,show指令是友善使用的簡短模式。
select table_name from tables where table_schema='jblog';
5. 檢視表結構
desc table_name;
6.檢視表狀态 show table status from db like 條件
可以檢視engine資料庫引擎,version,row、index等資訊
7.小技巧,當多行指令輸入,發現錯誤後,用\c結束。
-------------------------------------------------------------
另,查詢資料庫運作狀态的基本指令:
#查詢資料庫連接配接
show
full
processlist;
show status
like
'%Max_used_connections%'
;
show status
like
'%Threads_connected%'
;#目前連接配接數
show status
like
'%table_lock%'
;#表鎖定
show status
like
'innodb_row_lock%'
;#行鎖定
show status
like
'%qcache%'
; #查詢緩存情況
show variables
like
"%query_cache%"
;
SHOW STATUS
LIKE
'Qcache%'
;
show variables
like
"%binlog%"
;
show status
like
'Aborted_clients'
;#由于客戶沒有正确關閉連接配接已經死掉,已經放棄的連接配接數量
show variables
like
'%max_connections%'
;//檢視最大連接配接數量
show variables
like
'%timeout%'
;#檢視逾時時間
show variables
like
'log_%'
; #檢視日志是否啟動