Tuesday, 15 September 2015

To Find out If MySQL Is Running On Linux Or Not

Recently got a chance to work on Mysql database.So would like to share few besic article reagrding mysql Database.Below article will help you to check whether your mysql server is runnign or not.
You can use mysql startup script or mysqladmin command to find out if it is running on Linux. Then you can use ps command and telnet command too (it is not reliable but it works.). mysqladmin is a utility for performing administrative operations. You can also use shell script to monitor MySQL server. You can use mysqladmin as follows:
# mysqladmin -u root -p status

Output:
Enter password:
Uptime: 4  Threads: 1  Questions: 62  Slow queries: 0  Opens: 51  Flush tables: 1  Open tables: 45  Queries per second avg: 15.500
If MySQL serer is running it will display output as above. It displays uptime and number of queries etc. If server is not running then it will dump error as follows
# mysqladmin -u root -p status
Output:
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
Under Debian Linux you can type following command to find out if MySQL server is running or not

# /etc/init.d/mysql status

Output:
/usr/bin/mysqladmin  Ver 8.41 Distrib 4.1.15, for pc-linux-gnu on i486
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          4.1.15-Debian_1-log
Protocol version        10
Connection              Localhost via UNIX socket
UNIX socket             /var/run/mysqld/mysqld.sock
Uptime:                 4 min 16 sec
Threads: 1  Questions: 66  Slow queries: 0  Opens: 51  Flush tables: 1  Open tables: 45  Queries per second avg: 0.258
If you are using RedHat of Fedora then you can use following script"
# service mysqld status
OR
# /etc/init.d/mysqld status




 hope this article helped you. Your suggestions/feedbacks are most welcome.

Keep learning... Have a great day!!!


No comments:

Post a Comment