How To Control Output Formatting Via The MySQL Shell CLI
erics, Posted May 26th, 2021 at 3:32:31pm
1 |
mysql -N -B -e 'show variables like "%datadir%";' |
-N: No column headers
-B: Batch mode – use tabs as field separators
https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-output-formats.html
Multiple Formats Available:
Table Format – use --result-format=table
, alias --table
Tab Separated Format – use --result-format=tabbed
, alias --tabbed
Vertical Format – use --result-format=vertical
, alias --vertical
JSON Format Output – use --result-format=VALUE
, alias --json[=pretty|raw|off]
VALUE may be one of:
- json or json/pretty – These options both produce pretty-printed JSON.
- ndjson or json/raw – These options both produce raw JSON delimited by newlines.
- json/array – This option produces raw JSON wrapped in a JSON array.
Leave Your Comment
All fields marked with "*" are required.