SELECT
Data_BB / POWER(1024,1) Data_KB,
Data_BB / POWER(1024,2) Data_MB,
Data_BB / POWER(1024,3) Data_GB
FROM (SELECT SUM(data_length) Data_BB FROM information_schema.tables
WHERE table_schema NOT IN ('information_schema','performance_schema','mysql')) A;
mysqlSizeBytes="$(mysql --database=information_schema --skip-column-names --silent --execute "SELECT Data_BB FROM (SELECT SUM(data_length) Data_BB FROM information_schema.tables WHERE table_schema NOT IN ('information_schema','performance_schema','mysql')) A;")"
请运行此查询:
这会给你一个大概的数字。未使用该列
index_length
,因为 mysqldump 不转储索引,仅转储数据。为了安全起见,您应该始终立即对其进行 gzip 压缩:试试看 !!!
根据另一个答案,如果您想要一个衬线来确定在 shell 脚本中使用的字节大小,您可以使用这个: