Mysql怎么查询数据库连接状态
发布时间:2023-05-24 09:41:04 所属栏目:MySql教程 来源:
导读:本文小编为大家详细介绍“Mysql怎么查询数据库连接状态”,内容详细,步骤清晰,细节处理妥当,希望这篇“Mysql怎么查询数据库连接状态”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,
本文小编为大家详细介绍“Mysql怎么查询数据库连接状态”,内容详细,步骤清晰,细节处理妥当,希望这篇“Mysql怎么查询数据库连接状态”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。 查看显示所有数据库 mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | INVOICE | | mysql | | performance_schema | | test | +--------------------+ 5 rows in set (0.00 sec) mysql> 查看当前使用的数据库 mysql> select database(); +------------+ | database() | +------------+ | INVOICE | +------------+ 1 row in set (0.00 sec) mysql> 查看数据库使用端口 mysql> show variables like 'port'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | port | 3306 | +---------------+-------+ 1 row in set (0.00 sec) 查看当前数据库大小 例如,我要查看INVOICE数据库的大小,那么可以通过下面SQL查看 mysql> use information_schema Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select concat(round(sum(data_length)/(1024*1024),2) + round(sum(index_length)/(1024*1024),2),'MB') as 'DB Size' -> from tables -> where table_schema='INVOICE'; +-----------+ | DB Size | +-----------+ | 7929.58MB | +-----------+ 1 row in set, 1 warning (0.00 sec) 查看数据所占的空间大小 mysql> use information_schema; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select concat(round(sum(data_length)/(1024*1024),2),'MB') as 'DB Size' -> from tables -> where table_schema='INVOICE'; +-----------+ | DB Size | +-----------+ | 6430.26MB | +-----------+ 1 row in set, 1 warning (0.00 sec) mysql> 查看索引所占的空间大小 mysql> select concat(round(sum(index_length)/(1024*1024),2),'MB') as 'DB Size' -> from tables -> where table_schema='INVOICE'; +-----------+ | DB Size | +-----------+ | 1499.32MB | +-----------+ 1 row in set, 1 warning (0.13 sec) mysql> (编辑:汽车网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐