A few words of thanks would be greatly appreciated.

MySQL console: Redirect standard output


MySQL client command must be common to you (mysql), with this small tip you should be able to redirect the output commands to any program?


To do this, simply use the pager command, followed by the name of the program to redirect the output.
mysql>pager more 
PAGER set to 'more' 

The next time the result of a command exceeds one page, you simply press the space bar to move from page to page:)

Reset default pager

To return to the default pager, use the command "nopager":

mysql> nopager 
PAGER set to stdout 

Examples of use: (under Linux/Unix)

  • In order to search an item, ... in the output:
    •   mysql>pager vi - 
  • To view only the tables with a particular name (no case sensitive).
    •   mysql>pager grep -i name 
mysql>show tables;

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
This document, titled « MySQL console: Redirect standard output », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).