Checking That MySQL Server Is Working

You can use the mysqladmin or mysqlshow commands to check that the MySQL server is up and running. Here’s an example of how to check information about the MySQL server using the mysqladmin command.

# mysqladmin -u root -p version proc  Enter password: ********  mysqladmin  Ver 8.23 Distrib 3.23.58, for redhat-linux-gnu on i386  Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB  This software comes with ABSOLUTELY NO WARRANTY. This is free software,  and you are welcome to modify and redistribute it under the GPL license    Server version       3.23.58  Protocol version     10  Connection           Localhost via UNIX socket  UNIX socket          /var/lib/mysql/mysql.sock  Uptime:              2 days 10 hours 47 min 35 sec    Threads: 1  Questions: 184  Slow queries: 0  Opens: 1  Flush tables: 3  Open tables: 1 Queries per second avg: 0.001    +----+------+----------+------+-------+------+-----+------------------+  | Id | User | Host     | db   |Command| Time |State| Info             |  +----+------+----------+------+-------+------+-----+------------------+  | 52 | root | localhost|      | Query | 0    |     | show processlist |  +----+------+----------+------+-------+------+-----+------------------+ 

Each of the two options to mysqladmin shown here provides useful information. The version information shows the mysqladmin version is 8.23 and the number assigned to this distribution of the mysql server is 3.23.58. The binary package was created for PC versions of Linux/GNU on the i386 processor. The connection to the server is through a UNIX socket (mysql.sock) on the local host. The server has been up for 2 days, 10 hours, 47 minutes, and 35 seconds. Statistics show that there is one thread (connection to the server) currently active. There have been 184 requests to the server.

The proc option shows that one client is currently connected to the server. That client is logged into MySQL as the root user on the localhost. The client that has an Id of 52 (which tells you who the user is, allowing you to use that information, as the server’s administrator, if you wanted to disconnect the user) is currently querying the MySQL database.

If the server were not running at the moment, the mysqladmin command shown in the previous example would result in a failure message:

mysqladmin: connect to server at 'localhost' failed. 

Recommended remedies are to try to restart the server (by typing service mysqld restart) or to make sure that the socket exists (/var/lib/mysql/mysql.sock).

Red Hat Fedora Linux 3 Bible
Red Hat Fedora Linux 3 Bible
ISBN: 0764578723
EAN: 2147483647
Year: 2005
Pages: 286 © 2008-2017.
If you may any questions please contact us: