1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| -- 查询表空间大小
SELECT
table_schema AS `Database`,
table_name AS `Table`,
ROUND((data_length + index_length) / 1024 / 1024 / 1024, 2) AS `Size`
FROM
information_schema.tables
WHERE
table_schema NOT IN ('information_schema', 'mysql', 'performance_schema', 'sys')
ORDER BY
`Size` DESC;
-- 查询慢sql
SELECT * FROM information_schema.PROCESSLIST
WHERE COMMAND = 'Query' AND TIME > 1;
-- 数据库用户配置权限
-- 1查询数据库用户
select user from mysql.user;
-- 2创建用户
CREATE USER ha_xx@'%' IDENTIFIED BY ‘ha_xx@P123123123’;
-- 3查询某个用户的权限
show grants for read_all_prd;
-- 4给用户授权
grant select,insert,update on ha_xx.table to read_all_prd@‘%’;
|