My system requirement is to execute sequence of mysql commands from ubuntu terminal,
For testing I create a file query.sql on the desktop that have a content like:
create table aa (id int);
create tab bb (id int);
create table cc (id int);
I execute this with command like:
zero@zero-desktop:~/Desktop$ mysql --user=root --password=admin --database=zero <query.sql
My problem is if any query fail, script stop executing.
Can anybody tell me how I prevent it[ here only second have wrong syntax, first and third should be run]
I want to execute whole script, if any fail avoid it and start again from next query and generate a file where it shows error list……..
if you want to excute whole script file , no matter query is syntactically correct or not use this command
it will skip query if have problem and move to execute next query…
and finally you will get error list if there had any syntatically wrong query……
error will display on terminal like:-
ERROR 1064 (42000) at line 2: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syntax to use near ‘tab bb (id int)’ at line 1
ERROR 1050 (42S01) at line 3: Table ‘cc’ already exists
———–IS THERE ANY WAY TO KEEP THIS ERROR ON FILE RATHER THAN TERMINAL?———-