怎么做mysql查询系统_mysql系统信息查询(不完全,未做排版)

一)mysql> status 当前数据库的信息

二)mysql> show status(当前会话) 和show global status(全局)  查看服务器的状态信息

例如:

查看临时表:showglobal status like ‘created_tmp%‘;

三) mysql> show global variables 查看全局服务器运行各种状态值

例如:

连接数:              show variables like‘max_connections‘;

mysql的pid文件位置:  show variables like‘pid_file‘

mysql的字符集:       show variables like‘%character%‘;

查看数据文件存放位置:showvariables like ‘datadir‘;

查看内存占用(还需要在系统层面上查看ps-aux|grep mysql|awk ‘{print $3}‘)

SHOWVARIABLES LIKE ‘innodb_buffer_pool_size‘;

SHOWVARIABLES LIKE ‘innodb_additional_mem_pool_size‘;

SHOWVARIABLES LIKE ‘innodb_log_buffer_size‘;

SHOWVARIABLES LIKE ‘thread_stack‘;

四) mysql> show processlist  显示哪些线程正在运行

五) 数据库information_schema

mysql数据库安装后自带"information_schema"信息数据库。其中保存着关于MySQL服务器所维护的所有其他数据库的信息。如数据库名,数据库的表,表栏的数据类型与访问权限等。

在information_schema查整个库的占用空间状态和索引状态:

selectconcat(truncate(sum(data_length)/1024/1024,2),‘MB‘) as data_size,

concat(truncate(sum(max_data_length)/1024/1024,2),‘MB‘)as max_data_size,

concat(truncate(sum(data_free)/1024/1024,2),‘MB‘) asdata_free,

concat(truncate(sum(index_length)/1024/1024,2),‘MB‘) asindex_size

from information_schema.tables where TABLE_SCHEMA = ‘数据库名称‘;

查单表:

selectconcat(truncate(sum(data_length)/1024/1024,2),‘MB‘) as data_size,

concat(truncate(sum(max_data_length)/1024/1024,2),‘MB‘)as max_data_size,

concat(truncate(sum(data_free)/1024/1024,2),‘MB‘) asdata_free,

concat(truncate(sum(index_length)/1024/1024,2),‘MB‘) asindex_size

from information_schema.tables where TABLE_NAME = ‘表名称‘;

原文:http://zhangxiaohe.blog.51cto.com/7821029/1545481

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值