Script to list Database Disk Usage in Plesk

I recently used a script to list all MySQL databases available in a Plesk server with the disk usage. You can find the script below.

Script to list Database Disk Usage in Plesk

if [ -d /var/lib/mysql ]; then echo -ne "nn=== MySQL DATABASES ===n"; mysql -uadmin -p`cat /etc/psa/.psa.shadow` -e "SELECT round(sum( data_length + index_length )/1024/1024,0) 'SM', table_schema 'DN' FROM information_schema.TABLES GROUP BY table_schema ORDER BY SM DESC G;" | sed '/***/d' | sed 's/SM: //' | sed ':a;N;$!ba;s/nDN:/Mt/g'; fi;

=== MySQL DATABASES === 
128M wordpress_123
99M joomla_db
6M psa 
1M mysql
1M sitebuilder3
1M apsc
0M phpmyadmin_o_4xzIaYJJqD
0M information_schema
0M phpmyadmin_0K_TUOFIGdTW
0M sitebuilder5
0M horde
0M atmail

Fell free to modify.

LEAVE A REPLY

Please enter your comment!
Please enter your name here