June 18, 2012 · Mysql Mysql Client Logging

Client side logging in mysql

When using the mysql CLI users typically have two options when it comes to logging at the client side.

  1. Statement only logging can be found in ~/.mysql_history (see here
  2. Statement & result, etc logging can be obtained through the use of the tee and notee commands. The tee command specifies a file to record all subsequent output to, including statement and results. The notee command terminates the recording of the session.
mysql> tee /home/someuser/session_log_123.txt  
mysql> SELECT * FROM .....;  
mysql> ....some results  
mysql> notee 

mysql> \! cat /home/someuser/session_log_123.txt