|To run a batch script from the operating system command line, type something like this from the command prompt:|
This can be expanded as you like. Alternatively, you can put everything in run.sql.
This needs only:
(i) the mysql program in the current folder, or in the path
(ii) run.sql in the current folder
Pass params to a MySQL client script from a shell script:
In Linux, pass mysql command resultss to a variable:
Be careful with quotes; the entire $(...) must be enclosed in quotes, and so must be the MySQL command itself, so use different quote chars for the two.
Under Windows, the MySQL client script interface can be finicky. Substitute your MySQL username & password for USR and PWD, then this example works:
For example to parameterise Load Data Infile:
To redirect output including errors to a file, tell the OS to redirect
To redirect error messages only, use