简体   繁体   中英

MySQL command line run script twice

I'm trying to run a script with MySQL on Windows like this :

mysql.exe -h 127.0.0.1  databaseName -uroot < path\to\my\script.sql

On my script I do some stuff like this

select 'start'; 

select 'import';
SOURCE import some other sql with functions and procedures

select 'run';
some stuff

select 'end';

And when I'm looking for logs I found this :

start
start
import
import
run
run
end
end

Did you know why MySQL is doing this ?

Seem like

http://sqlfiddle.com/#!9/9eecb7d/98044

mysql is outputting column title and values.

To check this theory you can try http://sqlfiddle.com/#!9/9eecb7d/98046

select 'start' as my_command; 

or

select 'start' as step; 

You'll see the difference ;-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM