RSS
people

Check MySQL database size

Share/Save/Bookmark

How to check MySQL database size in your server? 
Actually MySQL already provide the information, what you need to do is just do a simple query to retrieve the data.

Below is the query :

SELECT table_schema "Data Base Name",
sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB",
sum( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
WHERE table_schema = '<DATABASE NAME>'
GROUP BY table_schema ;

3 Responses to “Check MySQL database size”

  1. Er Crini said:
    May 4th, 2009 at 4:42 pm

    Thanks dude, I’ve been locking for this one for a while. I’m impressed that everyone’s recommendation to know the size of a MySQL DB is “Install phpmyadmin and…”

    Now, I get the results just fine, except for the Free Space, that one is allways zero. Do you know what that could mean?

    1. nione said:
      June 30th, 2009 at 9:39 am

      I trying this gives me the error:

      1140 Mixing of GROUP columns (MIN(),MAX(),COUNT(),…) with no GROUP columns is illegal if there is no GROUP BY clause

      1. h2Guru said:
        August 28th, 2009 at 2:51 pm

        Hi nione,

        Thanks for your comments…
        I had amend the GROUP BY command in the query.
        It should be work now.

        Leave a Reply