I wouldn’t type a password after -p, because it lands in your shell history. MySQL ships a small tool that remembers it for you under a name.
Create an entry and type the password at the prompt:
mysql_config_editor set --login-path=shop \
--host=db.example.com --user=appadmin --password
From then on, one option replaces all of that:
mysql --login-path=shop
mysqldump --login-path=shop shopdb > shop.sql
Make as many paths as you have servers. To review them, with passwords masked:
mysql_config_editor print --all
Entries go into .mylogin.cnf in your home directory. It must be readable and writable by you alone, otherwise the programs ignore it. Anything you add on the command line still overrides the stored value, so --host can point the same credentials at another machine.
Don’t mistake it for a vault. The manual says plainly that the file is obfuscated, and that someone with administrator rights on the machine can recover the password with some effort. It keeps the secret out of history files, process lists and scripts you share, which is a real gain, and nothing more than that.
This tool belongs to MySQL’s own client package. MariaDB doesn’t include it, so on a MariaDB machine you’d use an option file with tight permissions.
Further reading: mysql_config_editor