N
nixsavy
Guest
This shell script can check if you have installed mysql and mysql-server packages in your Linux system.
Comments are provided over each line to understand the script better. Refer shell scripts programs to learn more.
Linux shell script
Shell script output:
Case 1 output cause:You have installed mysql and mysql-server packages.
#./mymysql.sh
You have installed mysql
You have installed mysql-server
Case 2 output cause:You have installed mysql,and not installed mysql-server.
#./mymysql.sh
You have installed mysql
MySQL-SERVER is not in your system.
Case 3 output cause:You haven't installed mysql,and installed mysql-server.
#./mymysql.sh
MySQL is not in your system.
You have installed mysql-server
Case 4 output cause:You haven't installed mysql and mysql-server.
#./mymysql.sh
MySQL is not in your system.
MySQL-SERVER is not in your system.
Comments are provided over each line to understand the script better. Refer shell scripts programs to learn more.
Linux shell script
#!/bin/bash
#check if installed mysql and mysql-server
MYMYSQL=
#get the mysql package's version
MYMYSQL=$(rpm -qi mysql|grep Version)
#Check if we have got the mysql version or not.If got,then we have installed mysql.
if [ -n "$MYMYSQL" ]
then
echo "You have installed mysql"
else
echo "MySQL is not in your system."
fi
MYMYSQL=
#get the mysql-server package's version
MYMYSQL=$(rpm -qi mysql-server|grep Version)
#Check if we have got the mysql-server version or not.If got,then we have installed mysql.
if [ -n "$MYMYSQL" ]
then
echo "You have installed mysql-server"
else
echo "MySQL-SERVER is not in your system."
fi
Shell script output:
Case 1 output cause:You have installed mysql and mysql-server packages.
#./mymysql.sh
You have installed mysql
You have installed mysql-server
Case 2 output cause:You have installed mysql,and not installed mysql-server.
#./mymysql.sh
You have installed mysql
MySQL-SERVER is not in your system.
Case 3 output cause:You haven't installed mysql,and installed mysql-server.
#./mymysql.sh
MySQL is not in your system.
You have installed mysql-server
Case 4 output cause:You haven't installed mysql and mysql-server.
#./mymysql.sh
MySQL is not in your system.
MySQL-SERVER is not in your system.