How to display MySQL or MariaDB server uptime

The following command is a example of how to display your MySQL, or MariaDB server uptime.

In the example below we are connecting to the SQL server as the user root and telling the client utility to prompt us for the password. If your my.cnf already contains a user and password you can remove the -u and -p options as they are not needed.

mysql -u root -p -e '\s'

Below is an example of what the output should look like

[root@server ~]# mysql -e '\s'
Enter password: <hidden>
mysql  Ver 15.1 Distrib 10.2.22-MariaDB, for Linux (x86_64) using readline 5.1
Connection id:          383224
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server:                 MariaDB
Server version:         10.2.22-MariaDB MariaDB Server
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    utf8
Conn.  characterset:    utf8
UNIX socket:            /var/lib/mysql/mysql.sock
Uptime:                 7 hours 46 min 2 sec
Threads: 66  Questions: 18880499  Slow queries: 0  Opens: 824083  Flush tables: 1  Open tables: 2000  Queries per second avg: 675.219