I usually include the password when I log in to MySQL. How do I exclude mysql -u root -pPassword
being picked up and stored by history?
I usually include the password when I log in to MySQL. How do I exclude mysql -u root -pPassword
being picked up and stored by history?
Put a space before your command.
This will work because, by default, the variable
$HISTCONTROL
containsignoreboth
which meansignorespace
andignoredups
;ignorespace
is what makes bash not save the command in history when there is a leading space.From
man bash
:If you want to exclude a certain command from Bash's history system wide, add the following to your
/etc/bash.bashrc
:This will exclude any command that starts with
mysql
.Execute
source /etc/bash.bashrc
to apply the changes.