RE: how to find the disk usage of mysql database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There are a number of ways at looking at this. The most accurate is to look
at the physical files on disk. The log files are stored in \MySQL Server
5.1\data\.

Each database then has it's own directory in this folder, so you could simply
add up all of the files in the folder to get the allocated size.

If you want to know how much of the allocated space you've used, then start
with System Variables -
http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html.

You can also calculate this on a table-by-table basis, using the table schema
:-

             SELECT *,
                    `TABLE_SCHEMA`       AS `Db`,
                    `TABLE_NAME`         AS `Name`,
                    `ENGINE`             AS `Engine`,
                    `ENGINE`             AS `Type`,
                    `VERSION`            AS `Version`,
                    `ROW_FORMAT`         AS `Row_format`,
                    `TABLE_ROWS`         AS `Rows`,
                    `AVG_ROW_LENGTH`     AS `Avg_row_length`,
                    `DATA_LENGTH`        AS `Data_length`,
                    `MAX_DATA_LENGTH`    AS `Max_data_length`,
                    `INDEX_LENGTH`       AS `Index_length`,
                    `DATA_FREE`          AS `Data_free`,
                    `AUTO_INCREMENT`     AS `Auto_increment`,
                    `CREATE_TIME`        AS `Create_time`,
                    `UPDATE_TIME`        AS `Update_time`,
                    `CHECK_TIME`         AS `Check_time`,
                    `TABLE_COLLATION`    AS `Collation`,
                    `CHECKSUM`           AS `Checksum`,
                    `CREATE_OPTIONS`     AS `Create_options`,
                    `TABLE_COMMENT`      AS `Comment`
               FROM `information_schema`.`TABLES`
              WHERE `TABLE_SCHEMA` IN (\'' . implode("', '", $databases) .
'\')

Take a look at phpMyAdmin, which displays all of sort of information. You can
then work out how it's derived.

Rob.

-----Original Message-----
From: php-objects@xxxxxxxxxxxxxxx [mailto:php-objects@xxxxxxxxxxxxxxx] On
Behalf Of Sudhakar
Sent: 29 January 2008 08:02
To: php-objects@xxxxxxxxxxxxxxx
Subject:  how to find the disk usage of mysql database

hi

i have mysql database installed on the main webserver and i use a pc 
through the lan. i have couple of tables in different databases.

my question is using php and mysql methods can i write a code which 
would connect to the server where mysql has been installed on the 
unix server and report on the following

1. total capacity of mysql database installed on the unix server's 
hard disk (this is NOT considering the entire capacity of the 
server's hard disk capacity ONLY the total amount of data capacity 
that mysql can hold on the unix server's hard disk)

2. total amount of data already used with the existing tables

3. amount of data left that the mysql database can accept

please provide the code.

thanks.


***********************************************************************************
Any opinions expressed in email are those of the individual and not necessarily those of the company. This email and any files transmitted with it are confidential and solely for the use of the intended recipient 
or entity to whom they are addressed. It may contain material protected by attorney-client privilege. If you are not the intended recipient, or a person responsible for delivering to the intended recipient, be advised that you have received this email in error and that any use is strictly prohibited.

Random House Group + 44 (0) 20 7840 8400
http://www.randomhouse.co.uk
http://www.booksattransworld.co.uk 
http://www.kidsatrandomhouse.co.uk
Generic email address - enquiries@xxxxxxxxxxxxxxxxx

Name & Registered Office:
THE RANDOM HOUSE GROUP LIMITED
20 VAUXHALL BRIDGE ROAD
LONDON
SW1V 2SA
Random House Group Ltd is registered in the United Kingdom with company No. 00954009, VAT number 102838980
***********************************************************************************


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux