您好,登錄后才能下訂單哦!
1.mysql 查看實例下,每個庫的大小 select TABLE_SCHEMA, concat(truncate(sum(data_length)/1024/1024,2),' MB') as data_size, concat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size from information_schema.tables group by TABLE_SCHEMA order by data_length desc; 2.mysql 查看具體某個庫里面的某個表的大小。 select concat(round(sum(DATA_LENGTH/1024/1024),2),'M') from tables where table_schema=\"${db}\" AND table_name=\"${table}\" 3.查看mysql 實例下,所有庫下的每個表的大小。 #!/bin/bash >allsize.txt for n in `cat mysqlbackuplist.txt` do echo ========= ${n} ========= >>allsize.txt for db in `mysql -uroot -ppassword -h$n -e 'show databases;' |awk 'NR>1{print $1}'|egrep -v 'schema|tmp|sys|innodb|mysql|tigasedb'` do >${db}size.txt echo ========= ${db} ========= echo ========= ${db} ========= >>allsize.txt for table in `mysql -uroot -ppassword -h$n -e "use ${db}; show tables"` do selectsql="select concat(round(sum(DATA_LENGTH/1024/1024),2),'M') from tables where table_schema=\"${db}\" AND table_name=\"${table}\";" mysql -uroot -ppassword -h$n -e "use information_schema; $selectsql" |awk -v table=$table 'NR>1{print table " " $1}' >>${db}size.txt done cat ${db}size.txt|sort -k 2 -rn >> allsize.txt done done
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。