MYSQL基本命令操做
1.登陆方法:mysql
mysql -u root -p
2.显示全部数据库:sql
show databases;
3.操做指定数据库(以information_schema为例)数据库
use information_schema
4.显示全部的表ide
show tables;
5.显示表结构(以users表为例)orm
discribe tables;
6.查询全部数据库的大小:it
select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables;
7.查询指定数据库的大小(以zabbix为例):io
select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='zabbix';
8.查询指定数据库中全部表的大小(以zabbix为例):table
SELECT TABLE_NAME,DATA_LENGTH+INDEX_LENGTH,TABLE_ROWS,concat(round((DATA_LENGTH+INDEX_LENGTH)/1024/1024,2), 'MB') as data
FROM information_schema.tables WHERE TABLE_SCHEMA='zabbix' ORDER BY DATA_LENGTH+INDEX_LENGTH desc;form
9.查询指定数据库中指定表的大小(以zabbix数据库的history表为例):class
select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='zabbix' and table_name='history';``