Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Though this might seem like a http://serverfault.com 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

1 Answer 1

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 :

database=databasename-you-want-by-default

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

[client]
host=localhost
user=root
password=root
database=mygotodb
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

 
discard

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.