I'm trying to pass parameter from bash script to mysql script. The bash script is
#!/bin/bash
for file in `ls *.symbol`
do
path=/home/qz/$file
script='/home/qz/sqls/load_eval.sql'
mysql -u qz -h compute-0-10 -pabc -e "set @pred = '$path'; source $script;"
done
The load_eval.sql is
use biogrid;
load data local infile @pred into table lasp
fields terminated by ','
lines terminated by '\n'
(score, symbols);
When running the bash script, I got error the message:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@pred into table lasp ..
It seems the value of the parameter @pred is not passed into mysql script.
echo "mysql ..."and see if you see something wrong in the statement or probably post the echo here to helppathis a bad choice for variable name, since it already has special meaning to the shell, use a different name, for examplefilepathorfullnamels *.symbol' + filepath=/home/qz/lasp/61304.pair.symbol + script=/home/qz/sqls/load_eval.sql + mysql --verbose -u qz -h compute-0-10 -pabc -e 'set @pred='\''/home/qz/lasp/61304.pair.symbol'\''; source /home/qz/sqls/load_eval.sql;' -------------- set @pred='/home/qz/lasp/61304.pair.symbol' -------------- -------------- load data local infile @pred into table lasp fields terminated by ',' lines terminated by '\n' (score, symbols) --------------