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