Solved

List Database Sizes For All MySQL 4.1 databases

Posted on 2011-09-14
5
776 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Fore-Foreword Today (2016) Maxmind has a new approach to the distribution of its data sets.  This article may be obsolete.  Instead of using the examples here, have a look at the MaxMind API (https://www.maxmind.com/en/geolite2-developer-package). …
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

786 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