I am trying to pass parameters to my sql script via cmd on Windows but it does not work nor do I get any errors though.
This will be running on a Windows environment and executed using cmd. I have the following code in my deploy.sql script:
INSERT INTO `database`.`users` (`id`, `first_name`, `last_name`, `username`, `active`)
VALUES (1, @first_name, @last_name, @user_name, 1);
I want to pass 3 strings to my script but it does not work. If I hard code a the strings in the script then I can execute the script via cmd perfectly.
The command I am trying to run to pass the parameters and execute the script is:
"C:\Program Files\MySQL\MySQL Server 5.7\bin\mysql.exe" -u root -p -e "set @first_name='John'; set @last_name='Smith'; set @user_name='john.smith';" < deploy.sql
My database is not updating nor do I get any errors. If I run the command with -v for a verbose output I get:
--------------
set @first_name='John'
--------------
--------------
set @last_name='Smith'
--------------
--------------
set @user_name='john.smith'
--------------