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?

link|improve this question

feedback

1 Answer

up vote 1 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
link|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
feedback

Your Answer

 
or
required, but never shown

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