开发者

How do you get table-formatted output from MySQL in non-interactive mode? [duplicate]

This question already has answers here: MYSQL differs in Output from script (2 answers) Closed 3 years ago.

I like the table output that the mysql client program produces in interactive mode, but if I try to run a sql script like this:

mysql -uroot mydb < myscript.sql

I only get tab-separated output.

mysql -uroot mydb -e 'select * from mytable'

does produce the output in the desired table format开发者_JAVA百科, however.

How can I get the first command to produce table-formatted output? I don't want HTML output, but the terminal character output with aligned columns and headers.


Add the -t option to mysql (table).

  mysql -t -uroot mydb < myscript.sql

  mysql -t -uroot mydb -e 'select * from mytable'


Use \P less -S option before running the query

mysql> \P less -S

PAGER set to 'less -S'

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜