Save mysql frame when linking files?

I have a question about mySQL / bash. here is my main situation

****> mysql -u**** -p*** -h*** -P*** -e "SELECT user,host,password FROM mysql.user WHERE password='*0F7947B374392A8F5638B396E0E4BB198D1D16D8'"
+--------------+------+-------------------------------------------+
| user         | host | password                                  |
+--------------+------+-------------------------------------------+
| *********    | %    | *0F7947B374392A8F5638B396E0E4BB198D1D16D8 |
| ************ | %    | *0F7947B374392A8F5638B396E0E4BB198D1D16D8 |
| *******      | %    | *0F7947B374392A8F5638B396E0E4BB198D1D16D8 |
+--------------+------+-------------------------------------------+


****> mysql -u**** -p*** -h*** -P*** -e "SELECT user,host,password FROM mysql.user WHERE password='*0F7947B374392A8F5638B396E0E4BB198D1D16D8'" >test.tmp; more test.tmp 
user    host    password
*********        %       *0F7947B374392A8F5638B396E0E4BB198D1D16D8
************     %       *0F7947B374392A8F5638B396E0E4BB198D1D16D8
*******    %       *0F7947B374392A8F5638B396E0E4BB198D1D16D8

When I output to the console, I get a nice even frame. What can I do to transfer this frame when I write it to a file? This will be part of a much larger script. I know that it would be possible to re-create the frame with awk, but I hope that it would just be portable. Thanks in advance!

+4
source share
2 answers

Use the parameter -tto explicitly display the table:

mysql -u**** -p*** -h*** -P*** -t -e "SELECT ..." > text.txt
+4
source
mysql -u**** -p*** -h*** -P*** --tab -e "SELECT user,host,password FROM mysql.user WHERE password='*0F7947B374392A8F5638B396E0E4BB198D1D16D8'" >test.tmp

Pay attention to -tab

+1
source

All Articles