Reputation: 332
I know that i can create some user-defined variables in MySQL and i also know how to use them. But I want to setup these variables in my batch file and execute a script where these variables are used.
I tried something like this and i see that the setup is working but the script.sql
file is NOT excecuted.
mysql -v -t -h %MySQL_SERV% -P %MySQL_PORT% -u %MySQL_ADMIN% --password=%MySQL_ADMINPASSWD% -D %MySQL_DB% -e "SET @1 = '"%MySQL_USER%"', @2 = '"%MySQL_PASSWD%"', @3 = '"%MySQL_SERV%"'; SELECT @1,@2,@3;" < script.sql
So how can I setup my variables that they can be used in my script.sql
Upvotes: 0
Views: 38
Reputation: 177
Try this :
mysql -v -t -h %MySQL_SERV% -P %MySQL_PORT% -u %MySQL_ADMIN% --password=%MySQL_ADMINPASSWD% -D %MySQL_DB% -e "SET @1 = '"%MySQL_USER%"', @2 = '"%MySQL_PASSWD%"', @3 = '"%MySQL_SERV%"'; SELECT @1,@2,@3; SOURCE script.sql;"
Upvotes: 1