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