How to know the MySQL uptime from commandline – 3 Methods

MySQL uptime.

In some situations, we need to check the uptime for MySQL in your server. We can not afford the downtime of a database engine. As a system engineer you must know the linux command-line options to find the uptime.

There are many ways to determine the uptime of MySQL engine.  The following command will give you the MySQL version along with the uptime of MySQL process.

What is MySQL performance tuning and what does it mean ?

MySQL has a lot of variables in its configuration. We can edit and set/alter variables to our requirements on our server. We can improve the MySQL performance by varying those values in configuration file.

A lot of methods and shell scripts are available for tuning your MySQL server. Here I am explaining the installation and usage of one shell script for tuning the MySQL.

This performance tuning shell script will help you to optimize your MySQL server on a huge traffic cPanel server. Read more..

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:

  1. Reset mysql root password from command line
  2. Allow mysql client to access remote mysql databases
  3. Create/restore MySQL dump/backup of all the databases.
  4. How to create a database and database user from command line
  5. Create a New Database-user and Grand Permissions

Post navigation

Arunlal Ashok

Linux Systems Architect at Endurance International Group. Linux lover. Like to play on Linux console. I started this blog to share and discuss Linux thoughts.

Always happy for an open discussion! Write to arun (@) crybit (dot) com. Check about me for more details. About this blog and our strong members, check The team CryBit.com

Leave a Reply

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