#!/bin/bash
mysql_srvr_name="xyz"
function run_msql(){
x=""
if [ $1 = "use" ]
then
x="-e \'$1 $2\'"
echo $x
elif [ $2 = "select" ]
then
x="-e \"$1 * from $2;\""
fi
mysql -h $mysql_srvr_name -P 3306 -u username -p"password" $x
}
I have created this function in a script file in ubuntu 16.04. whenever i try to run it for example as : run_msql use testdb
it gives me the following error:
ubuntu@xxx:~$ run_msql use testdb "use testdb" mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 1049 (42000): Unknown database 'testdb"'
~