如何禁止mysql記錄歷史命令?在執行 SQL命令時,mysql會將歷史命令記錄到~/.mysql_history文件中,因此我們用上下鍵就可以翻閱歷史命令了。
也許某些特殊需要我們可能需要不讓它記錄這些歷史命令,我們可以這樣作:
[root@TestServer root]# ln -s /dev/null $HOME/.mysql_history
這個方法來自官方手冊,下面是摘錄:
On Unix, the mysql client writes a record of executed statements to a history file. By default, the history file is named .mysql_history and is created in your home directory. To specify a different file, set the value of the MYSQL_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 following techniques:
Set the MYSQL_HISTFILE variable to /dev/null. To cause this setting to take effect each time you log in, put the setting in one of your shell’s startup files.
Create .mysql_history as a symbolic link to /dev/null:
shell> ln -s /dev/null $HOME/.mysql_history
You need do this only once.