Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Though this might seem like a question at first glance I don't think it is.
I have a mysql database on a server at work. Every time I log in to execute a query, I have to manually select the one database I want from the one database I have, which is a waste of time. Is there any way for me as an end user to set a default?

share|improve this question
up vote 3 down vote accepted

In the user's home directory (e.g. ~username) create a file named .my.cnf, or add to the existing .my.cnf file a line like :


Here are the contents of a typical .my.cnf:

share|improve this answer
Does the file have to be owned by mysql or can I just write it up myself? – Yitzchak Sep 13 '11 at 3:07
should be owned by the user, but so long as the user has read permissions that will suffice – Ram Sep 13 '11 at 18:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.