MySQL常用SQL语句

Posted

in

by


记录一些常用的MySQL语句,方便查找翻阅。

1. 统计数据库磁盘占用大小

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_size desc

2. 创建用户并授权

create user user@host identified by 'password';

grant all privileges on db.table to user@host;

flush privileges;

评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注