0

In windows mysql(5.7 version), I want to run mysql commmand using command line for .sql file as input . Also i was to pass some variable whose value should get used in .sql file. somehow I am not able to achieve it.

mysql -u root -p xyz  -e "set @tmp='abc'; source d:/v_test1.sql"

Here I want to file v_test1.sql having mysql code and also variable @tmp being used in v_test1.sql.

But getting error:

MySQL Error: Unknown column '@tmp' in 'field list'

I think issue might be because of version. Please suggest some solution.

1
  • Show us a line with @tmp in it.
    – Rick James
    Commented May 21, 2019 at 16:01

1 Answer 1

0

Try something like

echo set @tmp='abc'; > %temp%\temp.sql
copy /b %temp%\temp.sql+d:/v_test1.sql
mysql -u root -p xyz < %temp%\temp.sql
del %temp%\temp.sql

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.