You get a bonus - 1 coin for daily activity. Now you have 1 coin

MySQL: finding out database size from the console (bash/sh script or command line)

Practice



To find out the size of a specific database (in bytes) from the command line or a bash/sh script - run the following command:

mysql -u root -p -D <database name> -e "show table status\G"| egrep "(Index|Data)_length" | awk 'BEGIN { rsum = 0 } { rsum += $2 } END { print rsum }'


where you replace "root" (if needed) with the username that has access to this database, and "<database name>" - with the name of the database according to MySQL.

The result will be output in bytes.

Applies to: MySQL 5.x+

Comments

Guest 31-10-2020
топ

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Databases - MySql (Maria DB)"

Terms: Databases - MySql (Maria DB)