On Unix, the mysql client logs statements
executed interactively to a history file. By default, this file
.mysql_history in your home
directory. To specify a different file, set the value of the
MYSQL_HISTFILE environment variable.
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
mysql logs each nonempty statement line individually.
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:
In this case, mysql logs the
“SELECT”, “'Today is'”,
“,”, “CURDATE()”, and “;”
lines as it reads them. It also logs the complete statement,
SELECT 'Today is' ,
CURDATE(), plus a delimiter. Thus, these lines appear
in logged output:
SELECT 'Today is' , CURDATE() ; SELECT 'Today is' , CURDATE();
.mysql_history file should be protected
with a restrictive access mode because sensitive information
might be written to it, such as the text of SQL statements that
contain passwords. See Section 184.108.40.206, “End-User Guidelines for Password Security”.
If you do not want to maintain a history file, first remove
.mysql_history if it exists. Then use
either of the following techniques to prevent it from being
MYSQL_HISTFILEenvironment variable to
/dev/null. To cause this setting to take effect each time you log in, put it in one of your shell's startup files.
.mysql_historyas a symbolic link to
/dev/null; this need be done only once:
ln -s /dev/null $HOME/.mysql_history