This post shows how to get some MySQL status information from the command line on a Linux/Unix machine using either the mysqladmin command or the mysql init script. Information returned includes the version, connection type, socket file location, uptime and some other stats.
Using mysqladmin
Using mysqladmin is the only way to get the same sort of information across distros. The example provided in the "using the init script" section below works on Debian based distros and may or may not yield the same information for other distros. For example, on Red Hat / CentOS based distros the init script will only return the pid number and whether MySQL is running.
To get a basic set of stats run this:
This will show something like this:
To get more comprehensive information run this:
which will show something like this:
These first two examples are from MySQL running on a CentOS 5 server.
Using the init script
The init script at /etc/init.d/mysql on Debian based distros will return the same sort of status information as "mysqladmin status" when passed the "status" parameter. Run this:
This will show something like this:
This example is from a Debian 5 server.
Using the init script instead of mysqladmin means it can be run as the root user or using sudo without needing to know the mysql root user's password.
Remember this init script example on a Red Hat or CentOS based system will not show the same information but instead just that MySQL is running along with the pid number.
0 comments:
Post a Comment