If you open the mysql client with to -v
or --verbose
flag, it will echo the statement as well as the output.
$ mysql -v
mysql> tee output.txt
mysql> source myscript.sql
Update:
Note in the documentation for the --tee
option (or the tee
command):
Tee functionality works only in interactive mode.
This means it doesn't work when you run a script, and this limitation is documented. In other words, it works if you use source
as you are doing, but it doesn't work if you do this:
$ mysql -v --tee output.txt < myscript.sql