1. 程式人生 > >關於Mysql(MariaDB)的基本操作命令指南

關於Mysql(MariaDB)的基本操作命令指南

MariaDB Mysql

MYSQL基本命令操作

1.登錄方法:

mysql -u root -p

2.顯示所有數據庫:

show databases;

3.操作指定數據庫(以information_schema為例)

use information_schema

4.顯示所有的表

show tables;

5.顯示表結構(以users表為例)

discribe tables;

6.查詢所有數據庫的大小:

select concat(round(sum(data_length/1024/1024),2),‘MB‘) as data from tables;

7.查詢指定數據庫的大小(以zabbix為例):

select concat(round(sum(data_length/1024/1024),2),‘MB‘) as data from tables where table_schema=‘zabbix‘;

8.查詢指定數據庫中所有表的大小(以zabbix為例):

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;

9.查詢指定數據庫中指定表的大小(以zabbix數據庫的history表為例):

select concat(round(sum(data_length/1024/1024),2),‘MB‘) as data from tables where table_schema=‘zabbix‘ and table_name=‘history‘;``

關於Mysql(MariaDB)的基本操作命令指南