Log into MySQL databases via preconfigured aliases. Note that the alias name 'foo' is to be identified in the config file as 'clientfoo'.
$ cat ~/.bashrc
my() {
/usr/bin/mysql --defaults-group-suffix="$@"
}
myd() {
/usr/bin/mysqldump --defaults-group-suffix="$@"
}
$ ls -l ~/.my.cnf
-rw------- 1 dotancohen dotancohen 245 Apr 24 17:10 /home/dotancohen/.my.cnf
$ cat ~/.my.cnf
[clientfoo]
host=localhost
user=root
password=toor
[clientbar]
host=1.2.3.4
user=snowden
password=letmein
database=nsa_leaks
$ my foo
MySQL [(none)]> exit
$ my bar
MySQL [nsa_leaks]> exit