mysql — The MySQL Command-Line Client •  tee [ file_name ] ,  \T [ file_name ] •  use  db_name ,  \u  db_name •  warnings ,  \W •You can use it to write to a file and the results go only to the file: •In the preceding example, note the  -S  option. You may find it very useful for browsing wide query results. Sometimes a very wide result set is difficult to read on the screen. The  -S  option to  less  can make the result set much more readable because you can scroll it horizontally using the left-arrow and right-arrow keys. You can also use  -S  interactively within  less  to switch the horizontal-browse mode on and off. For more information, read the  less  manual page: •The  -F  and  -X  options may be used with  less  to cause it to exit if output fits on one screen, which is convenient when no scrolling is necessary: •You can specify very complex pager commands for handling query output: 438 The  prompt  command reconfigures the default  mysql>  prompt. The string for defining the prompt can contain the following special sequences. You can also combine the  tee  and  pager  functions. Have a  tee  file enabled and  pager  set to  less , and you are able to browse the results using the  less  program and still have everything appended into a file the same time. The difference between the Unix  tee  used with the  pager  command and the  mysql  built- in  tee  command is that the built-in  tee  works even if you do not have the Unix  tee  available. The built- in  tee  also logs everything that is printed on the screen, whereas the Unix  tee  used with  pager  does not log quite that much. Additionally,  tee  file logging can be turned on and off interactively from within  mysql . This is useful when you want to log some queries to a file, but not others. In this example, the command would send query results to two files in two different directories on two different file systems mounted on  /dr1  and  /dr2 , yet still display the results onscreen using  less . mysql>  pager cat | tee /dr1/tmp/res.txt \ | tee /dr2/tmp/res2.txt | less -n -i -S mysql>  pager less -n -i -S -F -X man less mysql>  pager less -n -i -S mysql>  pager cat > /tmp/log.txt You can also pass any options for the program that you want to use as your pager: Here are a few tips about the  pager  command: Enable display of warnings after each statement (if there are any). Use  db_name  as the default database. You can enable this feature interactively with the  tee  command. Without a parameter, the previous file is used. The  tee  file can be disabled with the  notee  command. Executing  tee  again re-enables logging. By using the  --tee  option when you invoke  mysql , you can log statements and their output. All the data displayed on the screen is appended into a given file. This can be very useful for debugging purposes also.  mysql  flushes results to the file after each statement, just before it prints its next prompt. Tee functionality works only in interactive mode.