MySQL常用SQL语句
记录一些常用的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;