bash_history 和 mysql_history

bash history

1 history

查看歷史命令

2 export HISTTIMEFORMAT='%F %T '

   history

查看帶上時間的歷史命令。

3 cat ~/.bash_history | less

 查看歷史命令文件。

4 !n

 執行編號爲n的歷史命令

5 history n

 顯示最近n條歷史命令。

6 ctrl+R+name

 搜索包含name的歷史命令,然後按↑↓鍵可以看到該命令相鄰的命令。

7 !name 

 執行以name開頭的命令

8 vim ~/.bash_profile

   HISTFILE=new history name

修改歷史命令保存的文件,默認在.bash_history中

9 history -c

  清除所有的歷史命令。


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.


發佈了57 篇原創文章 · 獲贊 6 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章