show status like 'Threads%';
```
mysql> show status like 'Threads%';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| Threads_cached | 58 |
| Threads_connected | 50 | 打开的连接数
| Threads_created | 3676 |
| Threads_running | 4 | 激活的连接数,这个数值远低于connected数值
+-------------------+-------+
```
当前设置的最大连接数
show variables like '%max_connections%';
查看当前用户权限
show grants;
查询版本
select @@version;或select version();
查看所有用户
SELECT User, Host, Password FROM mysql.user;
查看master状态
show master status;
查看slave状态
show slave status ;
查看所有数据库容量大小
select table_schema as '数据库',
sum(table_rows) as '记录数',
sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)',
sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'
from information_schema.tables
group by table_schema
order by sum(data_length) desc, sum(index_length) desc;
评论区