?
Solved

List Database Sizes For All MySQL 4.1 databases

Posted on 2011-09-14
5
Medium Priority
?
832 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
Minh Võ Công earned 1000 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 1000 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

770 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