3

I want to get database sizes for -

test, mysql, performance_schema, sakila, information_schema

[root@linux data]# ls -ltrh
总用量 32M
drwx------ 2 mysql root  4.0K 4月  27 17:44 test
drwx------ 2 mysql root  4.0K 4月  27 17:44 mysql
-rw-rw---- 1 mysql mysql  28K 4月  27 17:44 mysql-bin.000001
-rw-rw---- 1 mysql mysql 1.1M 4月  27 17:44 mysql-bin.000002
-rw-rw---- 1 mysql mysql  27K 4月  27 17:49 mysql-bin.000003
-rw-rw---- 1 mysql mysql 1.1M 4月  27 17:49 mysql-bin.000004
drwx------ 2 mysql mysql 4.0K 4月  27 17:50 performance_schema
-rw-rw---- 1 mysql mysql  27K 4月  27 17:50 mysql-bin.000005
-rw-rw---- 1 mysql mysql 1.1M 4月  27 17:50 mysql-bin.000006
-rw-rw---- 1 mysql mysql 5.0M 4月  27 18:02 ib_logfile1
-rw-rw---- 1 mysql mysql  238 4月  27 18:02 mysql-bin.index
srwxrwxrwx 1 mysql mysql    0 4月  27 18:02 mysql.sock
-rw-rw---- 1 mysql mysql    6 4月  27 18:02 mysql.pid
-rw-rw---- 1 mysql mysql 2.1K 4月  27 21:07 error.log
drwx------ 2 mysql mysql 4.0K 4月  27 21:51 lijunda
drwx------ 2 mysql mysql 4.0K 4月  28 09:12 sakila
-rw-rw---- 1 mysql mysql  22K 4月  28 09:12 mysql-bin.000007
-rw-rw---- 1 mysql mysql  18M 4月  28 09:12 ibdata1
-rw-rw---- 1 mysql mysql 5.0M 4月  28 09:12 ib_logfile0

when I use the command below, all directories become 4.0k. It's not what I wanted.

[root@linux data]# ls -ltrhd */
drwx------ 2 mysql root  4.0K 4月  27 17:44 test/
drwx------ 2 mysql root  4.0K 4月  27 17:44 mysql/
drwx------ 2 mysql mysql 4.0K 4月  27 17:50 performance_schema/
drwx------ 2 mysql mysql 4.0K 4月  27 21:51 lijunda/
drwx------ 2 mysql mysql 4.0K 4月  28 09:12 sakila/

How to display these directories proper size?

3

Try the command du(disk usage).

1
  • 2
    To get summarised results for each folder try du -s */. – Ezequiel Tolnay May 2 '16 at 6:06
1

I'd have commented the answer from torchhound... but I'm still too new for comments.
I also think du suits your need. I would use the -b (report in bytes) or -h (human readable), just to be sure of the magnitude of the numbers; otherwise you'll have to guess and although you will probably get it right, do it just in case.
My command line:

du -sb *

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.