我通常在登录到MySQL时包括密码。如何排除历史记录所收集和存储的mysql -u root -pPassword?
发布于 2014-09-26 14:55:24
在你的命令之前放一个地方。
这将起作用,因为在默认情况下,变量$HISTCONTROL包含ignoreboth,这意味着ignorespace和ignoredups;当有前导空间时,ignorespace是使bash在历史上不保存命令的原因。
来自man bash:
HISTCONTROL
A colon-separated list of values controlling how commands are saved on the history list. If the list of
values includes ignorespace, lines which begin with a space character are not saved in the history list.
A value of ignoredups causes lines matching the previous history entry to not be saved. A value of
ignoreboth is shorthand for ignorespace and ignoredups. A value of erasedups causes all previous lines
matching the current line to be removed from the history list before that line is saved. Any value not
in the above list is ignored. If HISTCONTROL is unset, or does not include a valid value, all lines read
by the shell parser are saved on the history list, subject to the value of HISTIGNORE. The second and
subsequent lines of a multi-line compound command are not tested, and are added to the history regardless
of the value of HISTCONTROL.如果要在Bash的历史系统范围内排除某个命令,请将以下内容添加到/etc/bash.bashrc中:
HISTIGNORE='mysql*'这将排除以mysql开头的任何命令。
执行source /etc/bash.bashrc以应用更改。
https://askubuntu.com/questions/528873
复制相似问题