Solved

List Database Sizes For All MySQL 4.1 databases

Posted on 2011-09-14
5
758 Views
Last Modified: 2012-08-14
Greetings,

Does anyone have a script that will list database sizes for all MySQL 4.1 databases? I have a script that will do it for MySQL 5.1 but that script does not work for MySQL 4.1.  Here's the script that works from me in MySQL 5.1:

SELECT NOW(), VERSION();

SELECT table_schema,

 SUM(data_length+index_length)/1024/1024 AS total_mb,

 SUM(data_length)/1024/1024 AS data_mb,

 SUM(index_length)/1024/1024 AS index_mb,

 COUNT(*) AS tables,

 CURDATE() AS today

FROM information_schema.tables

GROUP BY table_schema

ORDER BY 2 DESC;

# Set a session variable for the largest schema for later use

SELECT @schema := table_schema,

 SUM(data_length+index_length)/1024/1024 AS total_mb

FROM information_schema.tables

GROUP BY table_schema

ORDER BY 2 DESC

LIMIT 1;

Please HELP!

0
Comment
Question by:Omega002
  • 2
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
Minh Võ Công earned 250 total points
ID: 36540464
0
 

Author Comment

by:Omega002
ID: 36540533
This is pretty much the same script and it only works in MySQL 5.0 version not MySQL 4.1. I am looking for a script that will list database sizes for MySQL 4.1.
0
 
LVL 9

Expert Comment

by:blue_hunter
ID: 36541137
Can you attach the error message you gain while executing this SQL in MySQL 4.1?
0
 

Author Comment

by:Omega002
ID: 36541927
The information schema table does not exist in MySQL 4.1.
0
 
LVL 9

Assisted Solution

by:blue_hunter
blue_hunter earned 250 total points
ID: 36541960
then you have no choice but to go to the Mysql Data directory to check out the database table size

mostly is in /var/lib/mysql/<folder name = database name>


Command

shell> du -h
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now