Home
 

Customer Support

Search for keywords:

Browse by category:

How do I check how much disk space my database is
using?

You can check MySQL table size either by looking at phpMyAdmin in your control panel by clicking on the database name in the left frame and reading the size for the tables in there in the right frame, or instead, you can get a MySQL Monitor prompt and do:

show table status;


and look at the Data_length column for each table, which is in bytes.

This other FAQ tells you how we actually compute your disk usage.

User-Contributed Notes

add a note
24-Dec-2002 19:08
A quick script to show you how much disk space all your tables in a
database are using:

<?

  mysql_connect("db.modwest.com", "username", "password");
  mysql_select_db("yourdb");

  $result = mysql_query("show table status");

  $size = 0;
  $out = "";
  while($row = mysql_fetch_array($result)) {
      $size += $row["Data_length"];
      $out .= $row["Name"] .": ". 
                   round(($row["Data_length"]/1024)/1024, 2) ."<br>\n";
  }

  $size = round(($size/1024)/1024, 1);

  echo $out ."<br>\n";
  echo "Total MySQL db size: $size";
?>

03-Jan-2003 18:28
Actually if you really want to know the total disk usage, you need to
add in the index_length as well as the data_length in the script above.

anonymous -at- example.com
25-May-2009 02:09
If you simply want to know the total size, the query below will do the
trick (in bytes): 

select SUM(data_length) from information_schema.tables where
table_schema = 'mydb';

anonymous -at- example.com
11-Nov-2009 03:16
there is missing on the above comment.. it only summed the data_lenght..
it should be 

select SUM(data_length) + SUM(index_length) as size from
information_schema.tables where table_schema = 'mydb';

add a note

Related Questions:


How do I import delimited data into MySQL?

How do I import a MySQL dumpfile into my database?

How do I connect to my MySQL database?

How do I change my MySQL password?

How can I export data in CSV or tab delimited format?

Why do i get a query syntax error 1064 from MySQL when the syntax seems correct?

How do I export and move my database tables between servers or copy databases?

How do I create a .my.cnf MySQL preference file?

How do I change MySQL timezone?

I can't connect to local MySQL server through socket 'mysql.sock'

What is my database server name?

What is my MySQL Username or Database Name?

MySQL says I have too many connections.

A MySQL MYI table has errors in it.

Can I connect to MySQL remotely?

Can I connect to my MySQL database from my own computer?

I can't get phpMyAdmin to work.

phpMyAdmin gives SQL syntax error when I try to create table.

How can I use odbc_connect() in my PHP scripts to connect to MySQL?

What kind of database server do you offer?

How do I import a MySQL dumpfile into my database via phpMyAdmin?

How many databases do I get?

What am I allowed to do with my MySQL database?

Will we be able to do our own MySQL admin?

How do I export a MySQL dumpfile via phpMyAdmin?

Do you offer MySQL 5?

How do I create a MYSQL dumpfile?

How do I update my web application to connect to a different database server?

How do I create a MYSQL database for my webhosting account?

Browse Categories:

Getting Started, FTP, Telnet/SSH, Moving Domains, E-mail, Traffic Reports, Mailing Lists, Apache, PHP, CGI, Other Server-Side Scripting, MySQL Database, Imaging Libraries, Other Software, Billing & Terms, Control Panel, E-commerce, Pre-Sales


Modwest PHP Hosting      Copyright 2000-2010 by Modwest, Inc.      About    |    Blog    |    Community    |    Design    |    Jobs    |    Contact