I can echo the utility of
dbish. But I can also describe (but not share) a utility that my
$WORK uses internally. Our applications use YAML files to describe the different DB (mysql) servers to connect to on the different tiers - production, testing, development. We have a utility that is effectively a wrapper around
mysql and
mysqldump. It gets the authentication information from the same YAML file that the application(s) use on whatever box we're on.
In practice, we can do things at the commandline, like:
# send some SQL:
$ ourutil dbname < some.sql
$ cat some.sql | ourutil dbname
$ echo "SELECT * ..." | ourutil dbname
# dump out stuff
$ ourutil -D dbname [table] -- [extra mysqldump options]
Similarly, we can easily get to the shell via,
$ ourutil dbname
And if we just want to print the command string with the auth information in + options it would have executed, we can do:
$ ourutil --cmd # for mysql, or
$ ourutil -D --cmd # for mysqldump
I wish I could share the code, but the above interface should be readily implemented and customized to fit your existing environment. Update: just wanted to add, this utility I describe rarely changes and is extremely useful on a daily basis.