-->
🏠 🔍
SHAREOLITE

Beginners Linux shell script to view MySQL process , query status , table locks

Below mentioned is a beginners linux shell script to view the status of a MySQL processes , query status and search for any mysql table locks. This is useful to get an overall view of the current activities on MySQL database.

Copy the code below highlighted in blue , save it in a file and execute for output. There are variables DBUSER,DBPASS,DBHOST which be configured based on your installation.



#!/bin/sh
#################################################################################
# Configure the DB user name here.
# Ex. DBUSER="employee"
#################################################################################
DBUSER="employee"

#################################################################################
# Configure the DB user password here.
# Ex. DBPASS="test"
#################################################################################
DBPASS="m@gictest"

#################################################################################
# Connfigure the hostname here.
# Ex. DBHOST="10.10.23.114" . For localhost enter 127.0.0.1
#################################################################################
DBHOST="10.3.2.1"

#################################################################################

mysql -u $DBUSER -p$DBUSER -h $DBHOST << EOF

show processlist;

EOF

#################################################################################

Hope this is useful to some Linux beginners

Comments

–>