用户角色相关语句
创建用户
create user 'user1'@'localhost' identified by '123456';
create user 'user2'@'%' identified by '123456';
修改用户
alter user 'root'@'localhost' identified by '12345678';
数据库授权
grant all on db1.* to 'user1'@'localhost';
刷新权限
flush privileges;
检查视图
show table status where comment='view';
检查函数
select `name` from mysql.proc where db = '数据库名' and `type` = 'FUNCTION';
按数据库表数据大小排序
SELECT
TABLE_NAME,
DATA_LENGTH,
INDEX_LENGTH,
(DATA_LENGTH + INDEX_LENGTH) AS length,
TABLE_ROWS,
concat(
round(
(DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024,
3
),
'MB'
) AS total_size
FROM
information_schema. TABLES
WHERE
TABLE_SCHEMA = 'db1'
ORDER BY
length DESC