4.5.1.3 mysql Logging

On Unix, the mysql client logs statements
executed interactively to a history file. By default, this file
is named .mysql_history in your home
directory. To specify a different file, set the value of the
MYSQL_HISTFILE environment variable.

How Logging Occurs

Statement logging occurs as follows:

Statements are logged only when executed interactively.
Statements are noninteractive, for example, when read from a
file or a pipe. It is also possible to suppress statement
logging by using the --batch
or --execute option.

If a statement spans multiple lines (not including the
terminating delimiter), mysql
concatenates the lines to form the complete statement, maps
newlines to spaces, and logs the result, plus a delimiter.

Consequently, an input statement that spans multiple lines can
be logged twice. Consider this input:

mysql> SELECT
-> 'Today is'
-> ,
-> CONCAT()
-> ;

In this case, mysql logs the
“SELECT”, “'Today is'”,
“,”, “CONCAT()”, and “;”
lines as it reads them. It also logs the complete statement,
after mapping SELECT\n'Today
is'\n,\nCURDATE() to SELECT 'Today is' ,
CURDATE(), plus a delimiter. Thus, these lines appear
in logged output: