Show MySQL server uptime using a query

SHOW GLOBAL STATUS LIKE 'Uptime';

Result

+---------------+--------+
| Variable_name | Value  |
+---------------+--------+
| Uptime        | 322477 |
+---------------+--------+
1 row in set (0.00 sec)

(The uptime is given in seconds)
 

More status variables
There are many more status variables available.

Show them all with this query:

SHOW GLOBAL STATUS;

4 thoughts on “Show MySQL server uptime using a query

  1. Magesh M

    Alternatively use the below command’s becuase it will show clear details.
    a) mysqladmin -u root -p version

    After login to mysql server use the below command.

    mysql> \s

    Reply
  2. CedarTree

    Many of us might not have direct access to the database server or access to mysqladmin any way.

    Using a query is nice as you can use it to help monitor your database server without handing out a lot of remote access as well.

    All those stats are useful to someone monitoring stuff. Thanks!!

    Reply
  3. miltos

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

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Markdown is allowed in comments.