ok we will do a small exemple here:
first thing we will create a file sample.sh
we will write this:
#!/bin/bash
echo "welcome to our script"
echo "------------------------"
echo " drop database asterisk if exist"
mysql --user=cron --password=1234 --execute="DROP DATABASE IF EXISTS `asterisk`;"
echo "-----------------------"
echo "create asterisk database"
mysql --user=cron --password=1234 --execute="create database 'asterisk' default character set utf8 collate utf8_unicode_ci;
echo "---------------------------"
echo "use database asterisk"
mysql --user=cron --password=1234 --execute="use 'asterisk';"
echo "---------------------------"
echo" "create table mytable"
mysql --user=cron --password="CREATE TABLE 'mytable' (
'P_Id' int, 'LastName' varchar(255), 'FirstName' varchar(255), 'Address 'varchar(255), 'City' varchar(255) )"
echo "---------------------------"
echo "insert data in table mytable"
mysql --user=cron --password="INSERT INTO 'mytable' ('FirstName', 'Address', 'City') VALUES ('111', '222', '333');"
echo "---------------------------"
echo "bye bye"
then save your file sample.sh for exemple in /usr/local and run it
chmod 777 -R /usr/src/sample.sh
./usr/src/sample.sh
if they are same thing mistake please correct it
enjoy