Sunday, April 13, 2014

How to know the MySQL uptime from command line – 3 Methods

How to know the MySQL uptime from command line – 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:

root@web [/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

No comments:

Post a Comment