How to know the MySQL uptime from commandline – 3 Methods

In some strange situations, we need to check the uptime for MySQL in your server. The following command will give you the MySQL version along with the uptime of MySQL process.

Method I

# mysqladmin  version

Example:

# mysqladmin  version
mysqladmin  Ver 8.42 Distrib 5.5.35, for Linux on x86_64
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
....
....
Server version		5.5.35-cll
Protocol version	10
Connection		Localhost via UNIX socket
UNIX socket		/var/lib/mysql/mysql.sock
Uptime:			20 days 3 hours 16 min 18 sec
Threads: 5  Questions: 12009211  Slow queries: 0  Opens: 474165  Flush tables: 1  Open tables: 400  Queries per second avg: 6.902

Method II

# mysqladmin  ver

This command is similar to “mysqladmin version”

Example:

[email protected] [/home]# mysqladmin  ver
mysqladmin  Ver 8.42 Distrib 5.5.35, for Linux on x86_64
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
...
...
Server version		5.5.35-cll
Protocol version	10
Connection		Localhost via UNIX socket
UNIX socket		/var/lib/mysql/mysql.sock
Uptime:			20 days 3 hours 24 min 48 sec

Threads: 5  Questions: 12045578  Slow queries: 0  Opens: 474198  Flush tables: 1  Open tables: 400  Queries per second avg: 6.921

If you need to know only the MySQL uptime, then you can use grep command with the above mentioned command.

# mysqladmin  version | grep -i uptime
# mysqladmin  ver | grep -i uptime

Example:

# mysqladmin  ver | grep -i uptime
Uptime:			20 days 3 hours 27 min 37 sec

# mysqladmin  version | grep -i uptime
Uptime:			20 days 3 hours 19 min 28 sec

Method III

# mysqladmin status

This command also shows MySQL uptime along with running threads and queries, but this uptime is not in an easily understandable form. Here, uptime is recorded in seconds.
Example:

# mysqladmin status
Uptime: 1740953  Threads: 3  Questions: 12061095  Slow queries: 0  Opens: 474228  Flush tables: 1  Open tables: 400  Queries per second avg: 6.927

Cool 🙂

MySQL related:
Reset mysql root password from command line
How to allow mysql client to access remote mysql databases
How to create/restore MySQL dump/backup of all the databases.
How to create a database and database user from command line
create a New Database-user and Grand Permissions

Arunlal Ashok

Linux Server Administrator. I'm dealing with Linux servers since 2012. I started this blog to share and discuss my ideas with the world. Check My Profile!! in uPwork (oDesk) and let me know if you need any assistance. Thanks!!

You may also like...

Leave a Reply

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