How to escape ! in password?
Solution 1:
Use single quotes around the password like this: -p'one_@&!two'
To put it in an alias, you'd do something like:
alias runmysql='mysql -umyuser -p'\''one_@&!two'\'''
Solution 2:
-bash: !two: command not found
You also need to escape the &
character:
$ mysql -umyuser -pone_@\&\!two
Solution 3:
If you never use the ! history features, it might be more convenient to simply disable them (with set +H
in your bashrc).