MySQL Database Table Stats

Do you manage thousands of databases? I do. One of the really big challenges for me was to be able to report disk usage by table/db/data file/index so I whipped up this handy dandy ruby script to do it for me. My requirements were that it output to the command line and to a log file. Clearly the script needs access to an account that has SELECT privileges on all of the databases you want to report on. The command example can be seen through the “–help” flag. But it is fairly straight forward. Here is a screenshot of the results:

calc_mysql_usage screenshot

Essentially the script logs into your mysql server and does a “SHOW DATABASES” and then iterates through each. For each database listed it will run a show table status and then calculate the data and index space for you and display the itemized and aggregate data in an easy to read format. Please send me any questions you might have.

The script can be found here:

Calc_mysql_usage script


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

4 Responses to “MySQL Database Table Stats”

  1. Heh. Clever perhaps, but I prefer Excel.
    Kthanksbye.

  2. Sad ! The script link is broken :-/

  3. Wow, I just took it down too. It is a bit dated and really single purpose but I am working on a new project to get this data and more. You can follow it at:

    http://projects.splitbit.com/projects/show/rbmysqladmin

    Should have the functionality you are looking for very soon.

    -Daniel

  4. Yeah sorry about that. I am going to be publishing a full toolset in ruby for mysql. I first need to recover from back surgery.

Leave a Reply