How to Dump SQL Result to a Text File Using cli

Just a quick tip on how to dump a sql result to a txt file.

mysql -e “select * from [table]” -u[user] -p [database] > sqlresult.txt

For example:

[bash]mysql -e "select * from orders where product_id = 15" -uroot -p > sqlresult.txt[/bash]

Related: Some MySQL cli Syntax ExamplesBasic MySQL Performance MonitoringMySQL Performance Tuning Tips

One thought on “How to Dump SQL Result to a Text File Using cli

  1. Pingback: Copy Text From a File in Terminal | Curious Cat Coding

Comments are closed.