How to check MySQL Server startup time and uptime

How to check MySQL Server startup time and uptime

In this article, we will see how to check MySQL Server startup time and uptime.

Uptime is the time between current and MySQL start time.
Startup time is time exact time(date with seconds) of MySQL server started.

1. Check the MySQL Server Startup time:
We can get it from MySQL shell, Linux shell and MySQL workbench

Check the last startup time of MySQL:

a) By using sql statement on MySQL shell.

SELECT DATE_SUB(now(), INTERVAL variable_value SECOND) "LAST STARTUP" from performance_schema.global_status where variable_name='Uptime';

How to check MySQL Server startup time and uptime

b) From Linux shell.
Run either of below commands.

service mysql status systemctl status mysql

c) From MySQL Workbench.

Click on administration on MySQL workbench then click server status:

2. Check the MySQL Server uptime:

We can get it from MySQL shell and Linux shell

a) Check MYSQL uptime using SQL statement:

select TIME_FORMAT(SEC_TO_TIME(VARIABLE_VALUE ),'%Hh %im') as Uptime from performance_schema.global_status where VARIABLE_NAME='Uptime';

Select MYSQ uptime using SQL statement

SHOW GLOBAL STATUS LIKE 'Uptime'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | Uptime | 2130 | +---------------+-------+ 1 row in set (0.00 sec)

b) Get the MySQL uptime from Linux shell.

Run either of below commands.

service mysql status systemctl status mysql