Saturday, 15 March 2014

Script to list all MySQL databases and disk usage in Plesk

Script to list all MySQL databases and 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

No comments:

Post a Comment