Gossamer Forum
Home : General : Perl Programming :

Getting the size of a mysql-database with perl?

Quote Reply
Getting the size of a mysql-database with perl?
Hi,

anyone knows how to receive the actual size of a mysql-database with perl?

Thanks for hints.
Quote Reply
Re: [TB2] Getting the size of a mysql-database with perl? In reply to
This _may_ work:

my $dir = "/path/to/mysql/database/";

my $size = `du -ks $dir`;

Last edited by:

RedRum: Nov 11, 2001, 8:47 AM
Quote Reply
Re: [RedRum] Getting the size of a mysql-database with perl? In reply to
Hmm .. there must be another trick - phpmyadmin 2.2x displays the size of tables and databases without knowing the path to mysql ... my knowledge about PHP is too poor to see how they do this ...
Quote Reply
Re: [TB2] Getting the size of a mysql-database with perl? In reply to
Yeah but it has to make a database connection first which is more code.

The code above should work.

Last edited by:

RedRum: Nov 11, 2001, 8:49 AM
Quote Reply
Re: [RedRum] Getting the size of a mysql-database with perl? In reply to
Just playing with this ... if i enter

SHOW TABLE STATUS FROM database

into phpmyadmin i'll get two values (per table) shown: Data_length & Index_length.

Added those two values are the total size of the table ... if we get those values for all tables we'll have the total size of the database ... works fine for me ..

Last edited by:

TB2: Nov 11, 2001, 11:59 AM