Tell mysql to display output a page at a time, or run mysql in a window that allows scrollback.
If a statement produces many lines of output, normally the lines
just scroll right off the top of the screen. To prevent this, tell
mysql to present output a page at a
time by specifying the
--pager
option.[3]
--pager
=
program
tells
mysql to use a specific program as
your pager:
%mysql --pager=/usr/bin/less
--pager
by itself (with no option
value) tells mysql to use your
default pager, as specified in your PAGER
environment variable:
%mysql --pager
If your PAGER
variable isn’t set, you must either
define it or use the first form of the command to specify a pager
program explicitly. To define PAGER
, use the instructions given in Appendix B for setting environment variables.
Within a mysql session, you
can turn paging on or off using
P
or
, respectively. P
without an argument enables paging using
the program specified in your PAGER
variable. P
with an argument
enables paging using the argument as the name of the paging
program:
mysql>P
PAGER set to /bin/more mysql>P /usr/bin/less
PAGER set to /usr/bin/less mysql>PAGER set to stdout
Another way to deal with long result sets is to use a terminal program that allows you to scroll back through previous output. Programs such as xterm for the X Window System, Terminal for Mac OS X, or the console window for Windows allow you to set the number of output lines saved in the scrollback buffer. Under Windows, you can set up a console window that allows scrollback by using the following procedure:
Locate the Console item in the Control Panel or cmd.exe in the following directory: WINDOWSsystem32.
Create a shortcut to the item by right-clicking on it and dragging the mouse to where you want to place the shortcut (on the desktop, for example).
Right-click on the shortcut, and select the Properties item from the menu that appears.
Select the Layout tab in the resulting Properties window.
Set the screen buffer height to the number of lines you want to save, and click the OK button.
Now you can launch the shortcut to get a scrollable console window that allows output produced by commands in that window to be retrieved using the scrollbar.
3.144.172.38