不讓mysql記錄歷史命令 (轉本身的163博客)

  咱們在執行 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.
mysql