For MySQL you can specify your user and password in local config file (.my.cnf). This file should be in your home directory (i.e. ~/.my.cnf).

[mysql]
user=user
password=password