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.41 Distrib 5.0.22, 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 5.0.22   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: 2 Questions: 184 Slow queries: 0 Opens: 11 Flush tables: 1 Open   tables: 0 Queries per second avg: 0.004   +----+------+-----------+----+---------+------+-------+------------------+   Id User Host  db  Command  Time  State Info   +----+------+-----------+----+---------+------+-------+------------------+   2  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.41 and the number assigned to this distribution of the mysql server is 5.0.22. 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 2 (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. 

The recommended remedy is to try to restart the server (by typing service mysqld restart ).




Fedora 6 and Red Hat Enterprise Linux Bible
Fedora 6 and Red Hat Enterprise Linux Bible
ISBN: 047008278X
EAN: 2147483647
Year: 2007
Pages: 279

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net