侧边栏壁纸
  • 累计撰写 26 篇文章
  • 累计创建 25 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

MySQL常用查询命令

iRay
2022-10-23 / 0 评论 / 0 点赞 / 636 阅读 / 2826 字

查看当前连接数

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;
0

评论区