I'm not sure how your previous .my.cnf used to work, and I actually have never used these files before (mainly because I didn't know about them). So after a bit of research, I found this link and came up with the following ~/.my.cnf that worked for me:
password = mypass
database = dbname
host = server.location.com
and the command that reads it:
A couple things to point out (highlights from the article linked):
- group has to be preceded by 'client' to be read by mysql
- has to go after any [client] groups, otherwise it will be overridden
I tested this on mysql 5.5 on a Mac, worked great. And now that I know about them, I will use them!
After I set this up, I realized that the command line
mysql --defaults-group-suffix=dbid was a little hefty. So as added bonus, assuming you're running Linux/Mac/Etc do this:
echo 'alias mysql_dbid="mysql --defaults-group-suffix=dbid"' >> ~/.profile
dbid is the name of your suffix group.