以天为单位显示 MySQL 正常运行时间

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34609402/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 21:31:40  来源:igfitidea点击:

Display MySQL uptime in days

mysql

提问by Peter Penzov

I found this SQL query to display MySQL uptime:

我发现这个 SQL 查询可以显示 MySQL 的正常运行时间:

SHOW GLOBAL STATUS LIKE 'Uptime';

But I get the value 2059555.

但是我得到了 2059555 的值。

How I can convert it to days?

我如何将其转换为天?

回答by Big Data DBA

On MySQL prompt type this, On the last line we will find Uptime

在 MySQL 提示符下输入这个,在最后一行我们会找到 Uptime

mysql>\s

Also if needed to write a query. This will give you in hours and minutes

此外,如果需要编写查询。这会给你几小时和几分钟

select TIME_FORMAT(SEC_TO_TIME(VARIABLE_VALUE ),'%Hh %im')  as Uptime 
from information_schema.GLOBAL_STATUS 
where VARIABLE_NAME='Uptime'

Note:Above version 5.7 use performance_schema instead of information_schema

注意:5.7 以上版本使用 performance_schema 而不是 information_schema

回答by Ryan Marks

You can run SHOW GLOBAL STATUS;to find the value for Uptime, represented in seconds. Divide by 86,400 (60 * 60 * 24) to convert to days.

您可以运行SHOW GLOBAL STATUS;以查找 的值Uptime,以秒表示。除以 86,400 (60 * 60 * 24) 转换为天。

回答by Haohmaru

You can use MySQL Workbench (as it's free).

您可以使用 MySQL Workbench(因为它是免费的)。

Go under the tab Management > server status

转到选项卡下 Management > server status

it will show Running since: Mon Mar 20 15:29:45 2017 (1 hour)

它将显示 Running 自:Mon Mar 20 15:29:45 2017(1 小时)

enter image description here

在此处输入图片说明