If your query output is too long, this is easy way to log to a file
- Open MySQL REPL
- On command prompt enter
mysql> tee log.out Logging to file 'log.out'
- Now all your query output will be logged to file
log.out
on your working directory. - After exiting the MySQL command line you can see the file output
$ cat log.out
$ QUERY="select something from something"
$ MYSQL_HOST=myhost.mysql.com
$ MYSQL_USERNAME=readonly
$ MYSQL_PASSWORD=password
$ mysql -h $MYSQL_HOST -u$MYSQL_USERNAME -p$MYSQL_PASSWORD -se "$QUERY" >output.txt 2>&1
Now, see the output.txt.