Useful Snippets


This blog is used to collect useful snippets related to Linux, PHP, MySQL and more. Feel free to post comments with improvements or questions!

Are your smart devices spying on you? Make better purchasing choices and find products that respect your privacy at

RSS Latest posts from my personal blog

Most viewed posts

Subscribe to RSS feed

Show MySQL server uptime using a query

Stanislav KhromovStanislav Khromov


| 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:


Web Developer at Aftonbladet (Schibsted Media Group)
Any opinions on this blog are my own and do not reflect the views of my employer.
Twitter Profile
Visit my other blog

Comments 4
  • Magesh M
    Posted on

    Magesh M Magesh M

    Reply Author

    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

  • CedarTree
    Posted on

    CedarTree CedarTree

    Reply Author

    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!!

  • spam
    Posted on

    spam spam

    Reply Author

    spam spam spam

  • miltos
    Posted on

    miltos miltos

    Reply Author

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