Cómo obtener el tamaño de la base de datos mysql?
¿Cómo obtener el tamaño de una base de datos mysql?
Supongamos que la base de datos de destino se llama "v3".
7 answers
Ejecute esta consulta y probablemente obtendrá lo que está buscando:
SELECT table_schema "DB Name",
ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
FROM information_schema.tables
GROUP BY table_schema;
Esta consulta proviene de los foros mysql, donde hay instrucciones más completas disponibles.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-03-23 07:29:25
Se puede determinar usando el siguiente comando MySQL
SELECT table_schema AS "Database", SUM(data_length + index_length) / 1024 / 1024 AS "Size (MB)" FROM information_schema.TABLES GROUP BY table_schema
Resultado
Database Size (MB)
db1 11.75678253
db2 9.53125000
test 50.78547382
Obtener resultado en GB
SELECT table_schema AS "Database", SUM(data_length + index_length) / 1024 / 1024 / 1024 AS "Size (GB)" FROM information_schema.TABLES GROUP BY table_schema
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-06-19 09:53:19
Alternativamente, puede saltar directamente al directorio de datos y verificar el tamaño combinado de v3.myd, v3. myi y v3. archivos frm (para myisam) o v3.idb & v3.frm (para innodb).
Alternativamente, si está utilizando phpMyAdmin
, puede echar un vistazo a la suma de los tamaños de tabla en el pie de página de la pestaña de su base de datos structure
. El tamaño real de la base de datos puede ser ligeramente superior a este tamaño, sin embargo, parece ser consistente con el método table_schema
mencionado anteriormente.
Captura de Pantalla :
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-24 13:48:23
Para obtener un resultado en MB:
SELECT SUM(ROUND(((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024 ), 2)) AS "SIZE IN MB"
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = "SCHEMA-NAME";`
Para obtener un resultado en GB:
SELECT SUM(ROUND(((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024 /1024 ), 2)) AS "SIZE IN GB"
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = "SCHEMA-NAME";`
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-09-11 12:14:22
mysqldiskusage --server=root:MyPassword@localhost pics
+----------+----------------+
| db_name | total |
+----------+----------------+
| pics | 1,179,131,029 |
+----------+----------------+
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-11-29 20:16:49
Vaya al directorio de datos mysql y ejecute du-h max max-depth = 1 / grep databasename
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-06-13 20:19:31