Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 875
  • Last Modified:

List Database Sizes For All MySQL 4.1 databases

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
Omega002
Asked:
Omega002
  • 2
  • 2
2 Solutions
 
Minh Võ CôngCommented:
0
 
Omega002Author Commented:
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
 
blue_hunterCommented:
Can you attach the error message you gain while executing this SQL in MySQL 4.1?
0
 
Omega002Author Commented:
The information schema table does not exist in MySQL 4.1.
0
 
blue_hunterCommented:
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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now