Introduction
By default, the output of mysql in the console may be ugly when the screen is too small or the count of fields are large in the table. see the figure.
There are 2 alternative to prettify the output in the console.
1. Display Records Vertically
use \G
option rather than ;
.
SELECL * FROM user\G
2. Using Pager
pager less -SFX
SELECL * FROM user;
Advanced
Mysql provides user-specifc options file which allows mysql client read user's default configuration when connecting to mysql server.
The location of config file is at ~/.my.cnf
.
Here is an example:
[client]
pager='less -SFX'
- -S: Single line, don't skip line when line is wider than screen, instead allow to scroll to the right.
- -F: Quit if one screen, if content doesn't need scrolling then just send to stdout.
- -X: No init, disables any output “less” might have configured to output every time it loads.