Search  
   
Browse by Category
 
Netfirms 24/7 Support .: DATABASE MANAGEMENT .: How large is my MySQL database?

How large is my MySQL database?

To determine the size of your mySQL database, please follow these instructions (choose either Option I or Option II):

OPTION I

  1. Login to your Netfirms Members Control Panel at https://controlpanel.netfirms.com
  2. Click Hosting 
  3. Choose Databases
  4. Click MySQL  
  5. For the database you wish to administer, click the appropriate phpMyAdmin link
  6. Click your database id located on the left (eg. db6013598)
  7. Click SQL
  8. Run the following SQL query by entering the following command and clicking Go:

    show table status;
The Data_length AND Index_length columns are measured in bytes for each table...Total them up for the database size.

OPTION II

  1. Open a text editor (eg. Notepad)
  2. Copy and paste the code below into your text editor ( replace username, password and dbid accordingly):

     <html><head><title>mysql database size</title></head>

    <body> <h1>mysql database size</h1>

    <?php function file_size_info($filesize) {$bytes = array('KB', 'KB', 'MB', 'GB', 'TB');

    # values are always displayed

    if ($filesize < 1024) $filesize = 1;

    # in at least kilobytes.

    for ($i = 0; $filesize > 1024; $i++) $filesize /= 1024;

    $file_size_info['size'] = ceil($filesize);

    $file_size_info['type'] = $bytes[$i];

    return $file_size_info; } $db_server = 'mysqlhost'; $db_user = 'username'; $db_pwd = 'password'; $db_name = 'dbid';

    $db_link = @mysql_connect($db_server, $db_user, $db_pwd)

    or exit('Could not connect: ' . mysql_error()); $db = @mysql_select_db($db_name, $db_link) or exit('Could not select database: ' . mysql_error());

    // Calculate DB size by adding table size + index size:

    $rows = mysql_query("SHOW table STATUS"); $dbsize = 0;

    while ($row = mysql_fetch_array($rows)) {$dbsize += $row['Data_length'] + $row['Index_length']; } print "database size is: $dbsize bytes<br />"; print 'or<br />';

    $dbsize = file_size_info($dbsize); print "database size is: {$dbsize['size']} {$dbsize['type']}"; ?>

    </body></html>

  3. Save the file as database_size.php
  4. Using an FTP client (eg. Filezilla), connect to your Netfirms FTP account
  5. Access the www folder on your Netfirms FTP account
  6. Upload your database_size.php script to your Netfirms FTP account
  7. Browse to http://www.yourdomain.com/database_size.php to reveal your database size which will be auto-calculated

 


How helpful was this article to you?


.: Powered by Lore 1.5.6
Visit Netfirms.com Web Hosting | Copyright © 1998 - 2009 Netfirms, Inc. All Rights Reserved.