Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display MySQL uptime in days

Tags:

mysql

I found this SQL query to display MySQL uptime:

SHOW GLOBAL STATUS LIKE 'Uptime';

But I get the value 2059555.

How I can convert it to days?

like image 444
Peter Penzov Avatar asked Jan 05 '16 10:01

Peter Penzov


People also ask

How long has MySQL been up?

Officially, development of MySQL began in 1994. Shortly after that, on 23 May 1995, the first version of MySQL was released and the three developers founded MYSQL AB.

Is NULL in where MySQL?

To look for NULL values, you must use the IS NULL test. The following statements show how to find the NULL phone number and the empty phone number: mysql> SELECT * FROM my_table WHERE phone IS NULL; mysql> SELECT * FROM my_table WHERE phone = ''; See Section 3.3.

How do you set something to NULL in MySQL?

By using the assignment operator (“=”), you can set any value of a column to NULL by using the Update Statement.


2 Answers

On MySQL prompt type this, On the last line we will find 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

like image 56
koustuv Avatar answered Sep 22 '22 07:09

koustuv


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.

like image 42
Ryan Marks Avatar answered Sep 21 '22 07:09

Ryan Marks