温馨提示×

mysql怎么查询数据库大小

小亿
108
2024-02-27 13:40:26
栏目: 云计算

可以通过以下步骤查询MySQL数据库的大小:

1、登录MySQL数据库

```

mysql -u username -p

```

2、选择要查询的数据库:

```

use database_name;

```

3、运行以下查询语句:

```

SELECT table_schema "Database Name",

sum(data_length + index_length) / 1024 / 1024 "Database Size (MB)"

FROM information_schema.TABLES

GROUP BY table_schema;

```

这个查询语句会返回所有数据库的大小(以MB为单位),包括数据和索引的大小。

0