Related Documentation Download this Manual
PDF (US Ltr) - 324.6Kb
PDF (A4) - 323.4Kb
HTML Download (TGZ) - 64.3Kb
HTML Download (Zip) - 74.9Kb


MySQL Shell 8.0  /  MySQL Shell Code Execution  /  Output Formats

4.6 Output Formats

MySQL Shell can print results in table, tabbed, or vertical format, or as pretty or raw JSON output. From MySQL Shell 8.0.14, the MySQL Shell configuration option resultFormat can be used to specify any of these output formats as a persistent default for all sessions, or just for the current session. Changing this option takes effect immediately. For instructions to set MySQL Shell configuration options, see Section 8.4, “Configuring MySQL Shell”. Alternatively, the command line option --result-format or its aliases (--table, --tabbed, --vertical) can be used at startup to specify the output format for a session. For a list of the command line options, see Section A.1, “mysqlsh — The MySQL Shell”.

If the resultFormat configuration option has not been specified, when MySQL Shell is in interactive mode, the default format for printing a result set is a formatted table, and when MySQL Shell is in batch mode, the default format for printing a result set is tab separated output. When you set a default using the resultFormat configuration option, this default applies in both interactive mode and batch mode.

To help integrate MySQL Shell with external tools, you can use the --json option to control JSON wrapping for all MySQL Shell output when you start MySQL Shell from the command line. When JSON wrapping is turned on, MySQL Shell generates either pretty-printed JSON (the default) or raw JSON, and the value of the resultFormat MySQL Shell configuration option is ignored. When JSON wrapping is turned off, or was not requested for the session, result sets are output as normal in the format specified by the resultFormat configuration option.

The outputFormat configuration option is now deprecated. This option combined the JSON wrapping and result printing functions. If this option is still specified in your MySQL Shell configuration file or scripts, the behavior is as follows:

  • With the json or json/raw value, outputFormat activates JSON wrapping with pretty or raw JSON respectively.

  • With the table, tabbed, or vertical value, outputFormat turns off JSON wrapping and sets the resultFormat configuration option for the session to the appropriate value.