When performing a non-READ MySQL query from the terminal or a bash script, it’s normal to get no output.
In my case, I need a bash script to delete a vast number of records. When no rows are affected, then need to perform PURGE
and OPTIMIZE
.
To achieve this, I require the output when running the DELETE
query to look like this:
Query OK, 1 rows affected (0.023 sec)
However, as stated above, non-READ queries produce no output when executed from the terminal or bash.
Fortunately, the solution is simple: just add the -vv
flag to mysql -e
to make it more verbose.
Now, I can retrieve the affected rows from the bash script.