1:show databases;
查看所有的數據庫,等同於select schema_name from information_schema.schemata\G。\G 替換;,以縱向報表的形式輸出結果,有利於閱讀。
- status 查看mysql數據庫的運行狀態
- use 命令選擇數據庫 例如 use information_schema,當使用此命令后
select schema_name from information_schema.schemata\G,可以為
select schema_name from schemata\G
- 查看數據庫中的表
show tables
同樣也可以在information_schema中查看,show命令是方便使用的簡短模式。
select table_name from tables where table_schema='jblog';
- 查看表結構
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_%'``; #查看日志是否啟動