1 command line access to database
[Email protected] ~]# mysql-uroot-penter Password:
2 Viewing the database
Mysql> Show databases;+--------------------+| Database |+--------------------+| Information_schema | | MySQL | | Test |+--------------------+
3 View Information_schema's "TABLES"
Mysql> Use information_schema;| TABLES |
4 Viewing the field structure
mysql> desc tables;+-----------------+---------------------+------+-----+---------+-------+| Field | Type | null | key | default | extra |+-----------------+---------------------+------+-----+---------+ + ------+| table_catalog | varchar ( ) | NO | | | | | table_schema | varchar ( ) | NO | | | | | table_name &nbsP; | varchar ( | NO ) | | | | | table_type | varchar ( ) | NO | | | | | engine | varchar ( ) | YES | | NULL | | | version | bigint (+) unsigned | yes | | null | | | row_format | varchar (Ten) | yes | | null | | | table_rows | bigint (+) unsigned | YES | | NULL | | | avg_row_length | bigint (+) unsigned | YES | | null | | | data_length | bigint (+) unsigned | yes | | null | | | max_data_length | bigint (+) unsigned | yes | | null | | | index_length | bigint (+) unsigned | YES | | null | | | data_free | bigint (+) unsigned | YES | | NULL | | | auto_increment | bigint (+) unsigned | YES | | null | | | CREATE_TIME | datetime | yes | | null | | | UPDATE_TIME | datetime | YES | | NULL | | | CHECK_TIME | datetime | YES | | NULL | | | table_collation | varchar (+) | yes | | NULL | | | checksum | bigint (+) unsigned | YES | | null | | | create_options | varchar (255) | yes | | NULL | | | table_comment | varchar (2048) | no | | | |+-----------------+---------------------+------+-----+---------+--- ----+
5 Viewing the data size of the DB
Mysql> select table_schema,round (SUM (data_length)/1024/1024,2) as table_size from tables group by table_schema;+--------------------+------------+| table_schema | table_size |+--------------------+------------+| bomo_ backend | 0.09 | | test1 | 234.16 | | test2 | 0.17 | | information_schema | 0.00 | | mysql | 0.71 | | performance_schema | 0.00 | | test | 0.03 |+--------------------+------------+
6 Viewing the table's data size
Mysql> select table_schema,table_name,concat (Round (data_length/1024/1024,2), ' M ') as table_size from tables where table_schema = ' grab '; +--------------+------------- -+------------+| table_schema | table_name | table_size |+---------- ----+--------------+------------+| grab | product | 215.12m | | grab | result | 13.52m | | grab | rule | 0.02m | | grab | task | 5.52m |+--------------+--------------+------------+
This article from "Old Cannon Son" blog, reprint please contact the author!
Mysql View Database size