データベースのサイズはほっとくと膨れ上がったりして障害に繋がったりするので、定期的に確認をするのがベストなのでですが
コマンドが長いのでメモ書きです
データベースのサイズを確認する
データベースのサイズを確認するには、以下のコマンドを実行します。
SELECT
table_schema as DB名, sum(data_length) /1024/1024 AS MB容量
FROM
information_schema.tables
GROUP BY
table_schema
実行結果
分かりやすいように項目名を日本語にしています。
+--------------------+------------+
| DB名 | MB容量 |
+--------------------+------------+
| information_schema | 0.08593750 |
| mysql | 0.59897423 |
| performance_schema | 0.00000000 |
| sasukepg | 6.10937500 |
+--------------------+------------+
4 rows in set (0.01 sec)
テーブルのサイズ
テーブルのサイズを確認するには、以下のコマンドを実行します。
select
table_name, engine,
floor((data_length+index_length)/1024/1024) as 総容量MB
from information_schema.tables
where table_schema=database()
実行結果
+--------------------------------+--------+-------------+
| table_name | engine | 総容量MB |
+--------------------------------+--------+-------------+
| wp_posts | InnoDB | 3 0|
|| wp_postmeta | InnoDB | 50 |
以下省略