Mysql 查看資料庫大小

來源:互聯網
上載者:User

標籤:mysql   資料庫   

1 命令列進入資料庫

[[email protected] ~]# mysql -uroot -pEnter password:

2 查看資料庫

mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || mysql              || test               |+--------------------+

3 查看information_schema的"TABLES"

mysql> use information_schema;| TABLES                                |

4 查看欄位結構

mysql> desc tables;+-----------------+---------------------+------+-----+---------+-------+| Field           | Type                | Null | Key | Default | Extra |+-----------------+---------------------+------+-----+---------+-------+| TABLE_CATALOG   | varchar(512)        | NO   |     |         |       || TABLE_SCHEMA    | varchar(64)         | NO   |     |         |       || TABLE_NAME      | varchar(64)         | NO   |     |         |       || TABLE_TYPE      | varchar(64)         | NO   |     |         |       || ENGINE          | varchar(64)         | YES  |     | NULL    |       || VERSION         | bigint(21) unsigned | YES  |     | NULL    |       || ROW_FORMAT      | varchar(10)         | YES  |     | NULL    |       || TABLE_ROWS      | bigint(21) unsigned | YES  |     | NULL    |       || AVG_ROW_LENGTH  | bigint(21) unsigned | YES  |     | NULL    |       || DATA_LENGTH     | bigint(21) unsigned | YES  |     | NULL    |       || MAX_DATA_LENGTH | bigint(21) unsigned | YES  |     | NULL    |       || INDEX_LENGTH    | bigint(21) unsigned | YES  |     | NULL    |       || DATA_FREE       | bigint(21) unsigned | YES  |     | NULL    |       || AUTO_INCREMENT  | bigint(21) unsigned | YES  |     | NULL    |       || CREATE_TIME     | datetime            | YES  |     | NULL    |       || UPDATE_TIME     | datetime            | YES  |     | NULL    |       || CHECK_TIME      | datetime            | YES  |     | NULL    |       || TABLE_COLLATION | varchar(32)         | YES  |     | NULL    |       || CHECKSUM        | bigint(21) unsigned | YES  |     | NULL    |       || CREATE_OPTIONS  | varchar(255)        | YES  |     | NULL    |       || TABLE_COMMENT   | varchar(2048)       | NO   |     |         |       |+-----------------+---------------------+------+-----+---------+-------+

5 查看DB的資料大小

mysql> select table_schema,round(sum(DATA_LENGTH)/1024/1024,2) as table_size from tables group by table_schema;+--------------------+------------+| table_schema       | table_size |+--------------------+------------+| bomo_backend       |       0.09 || test1              |     234.16 || test2              |       0.17 || information_schema |       0.00 || mysql              |       0.71 || performance_schema |       0.00 || test               |       0.03 |+--------------------+------------+

6 查看table的資料大小

mysql> select table_schema,table_name,concat(round(data_length/1024/1024,2),‘M‘) as table_size from tables where table_schema = ‘grab‘;+--------------+--------------+------------+| table_schema | table_name   | table_size |+--------------+--------------+------------+| grab         | product      | 215.12M    || grab         | result       | 13.52M     || grab         | rule         | 0.02M      || grab         | task         | 5.52M      |+--------------+--------------+------------+


本文出自 “老炮兒” 部落格,轉載請與作者聯絡!

Mysql 查看資料庫大小

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.