We will initially start by checking which version of MySQL is installed. With this script, we will ensure that MySQL is properly installed and we are able to communicate with it with root privileges. This script will report us the database version of MySQL. It executes a SELECT VERSION() query to get the value of the database version. Let's create the script mysql_01.sh:
#!/bin/bash mysql -u root -pTraining2@^ <<MY_QUERY SELECT VERSION(); MY_QUERY
Save the program and execute it as follows:
$ chmod +x mysql_01.sh $ ./mysql_01.sh
The output will be:
VERSION() 5.7.22