我们在执行 SQL命令时,mysql会将历史命令记录到~/.mysql_history文件中,因此我们用上下键就可以翻阅历史命令了。
也许某些特殊需要我们可能需要不让它记录这些历史命令,我们可以这样作:

1
[root@TestServer root]# ln -s /dev/null $HOME/.mysql_history

这个方法来自官方手册,下面是摘录:

On Unix, the mysql client writes arecord of executed statements to a history file. By default, thehistory file is named .mysql_history and is created in your homedirectory. To specify a different file, set the value of theMYSQL_HISTFILE environment variable.

If you do not want to maintain a history file, first remove.mysql_history if it exists, and then use either of the followingtechniques:

Set the MYSQL_HISTFILE variable to /dev/null. To cause this setting totake effect each time you log in, put the setting in one of yourshell’s startup files.

Create .mysql_history as a symbolic link to /dev/null:

1
shell> ln -s /dev/null $HOME/.mysql_history

You need do this only once.