TA的每日心情 | 开心 2023-8-9 11:05 |
---|
|
--查看数据库
--查看数据文件位置
- show variables like 'datadir';
复制代码 --查看数据库错误日志
- show variables like 'log_error';
复制代码 --查看从库主机
--查看默认存储引擎
- show variables like 'default_storage_engine';
复制代码 --查询查询系统变量
- show global status;
- show variables \G
复制代码 --查询版本
--查询插件使用情况
- select plugin_name,plugin_status,load_option from information_schema.plugins;
复制代码 --查询用户和密码
- mysql> select user,host,password[authentication_string] from mysql.user;
复制代码 --查询数据库数据量
- select concat(round(sum((data_length+index_length) / 1024 / 1024), 2), 'MB') as tb_id_size from information_schema.tables;
复制代码 --查询用户数据量
- select table_schema,
- concat(round(sum((data_length + index_length) / 1024 / 1024), 2),
- 'MB') as data_size
- from information_schema.tables
- group by table_schema
- order by 2 desc;
复制代码 --查询当前在线用户
- SELECT DISTINCT CONCAT('User: ''', user, '''@''', host, ''';') AS query FROM mysql.user;
- select user,current_connections from performance_schema.users where user is not null;
复制代码 --查询进程
--查询全局状态
- select * from performance_schema.global_status\G;
复制代码 --查询全局变量
- select * from performance_schema.global_variables\G;
复制代码 --查询TPS
- use information_schema;
- select VARIABLE_VALUE
- into @num_com
- from GLOBAL_STATUS
- where VARIABLE_NAME = 'COM_COMMIT';
- select VARIABLE_VALUE
- into @num_roll
- from GLOBAL_STATUS
- where VARIABLE_NAME = 'COM_ROLLBACK';
- select VARIABLE_VALUE
- into @uptime
- from GLOBAL_STATUS
- where VARIABLE_NAME = 'UPTIME';
- select (@num_com + @num_roll) / @uptime;
复制代码 --查询QPS
- use information_schema;
- select VARIABLE_VALUE
- into @num_queries
- from GLOBAL_STATUS
- where VARIABLE_NAME = 'QUESTIONS';
- select VARIABLE_VALUE
- into @uptime
- from GLOBAL_STATUS
- where VARIABLE_NAME = 'UPTIME';
- select @num_queries / @uptime;
复制代码 |
|