首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >历史条目

历史条目
EN

Ask Ubuntu用户
提问于 2014-09-26 14:08:29
回答 1查看 387关注 0票数 2

我通常在登录到MySQL时包括密码。如何排除历史记录所收集和存储的mysql -u root -pPassword

EN

回答 1

Ask Ubuntu用户

回答已采纳

发布于 2014-09-26 14:55:24

在你的命令之前放一个地方。

这将起作用,因为在默认情况下,变量$HISTCONTROL包含ignoreboth,这意味着ignorespaceignoredups;当有前导空间时,ignorespace是使bash在历史上不保存命令的原因。

来自man bash

代码语言:javascript
复制
  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中:

代码语言:javascript
复制
HISTIGNORE='mysql*'

这将排除以mysql开头的任何命令。

执行source /etc/bash.bashrc以应用更改。

来源:https://unix.stackexchange.com/questions/32460/excluding-some-of-the-commands-from-being-getting-stored-in-bash-history

票数 2
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/528873

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档