TL;DR — Resumo Rápido
A consulta de tamanho de banco de dados MySQL usando information_schema permite verificar dados e espaço livre de todos os bancos em segundos, sem ferramentas GUI ou acesso root.
Nota: Este artigo foi publicado originalmente em 2014. Alguns passos, comandos ou versões de software podem ter mudado. Consulte a documentação atual de MySQL para as informações mais recentes.
How to: Get the size of your Databases in MySQL Query Browser
Imagine you want to transfer data from one server to another and you need to know the size of the databases you are thinking of transfering. Unlike Microsoft SQL Server which graphical interface allows you to see the size of the database files and the amount of data stored (http://mysqlworkbench.org/ “MySQL Workbench”) does not have a section that allows you to do just that (or at least I haven’t found it yet). The good news is that you only need to run a simple query in order to obtain a table listing the different tables in your server as well as the size of the databases. Below is the SQL script:
SELECT table_schema “Data Base Name”, sum( data_length + index_length ) / 1024 / 1024 “Data Base Size in MB” FROM information_schema.TABLES GROUP BY table_schema ;
As you would expect the space available can also be queried via a SQL script on your Query Browser like so:
SELECT table_schema “Data Base Name”, sum( data_length + index_length ) / 1024 / 1024 “Data Base Size in MB”, sum( data_free )/ 1024 / 1024 “Free Space in MB” FROM information_schema.TABLES GROUP BY table_schema ;