Fast way to send mysql query results

Is there an easy way to send mysql query results from mysql console directly or from linux console? Good formatting is a bonus.

+6
source share
3 answers
mysql -u .. -p.. -H <<<"your query" | mutt -s 'subject' email@email.com 

if you think HTML formats better

I personally prefer \G

 mysql -u .. -p.. -N <<<"your query\G" | mail -s 'subject' email@email.com 
+6
source

An alternative to the other mutt answer is just the old mail from the mailx package:

 mysql -uuser -ppass dbname < queryfile.sql | mail -s 'Your query output' email@example.com 
+1
source
 mysql -u <user> -p<password> <database> -e "<query>" | sendmail <emailaddress> 
0
source

Source: https://habr.com/ru/post/896424/


All Articles