Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

I googled a while but couldn't find an answer. Although it is often explained, how you simply could put a .my.cnf into your /root and make your funny full database dumps without having to enter a password.


mysqldump --complete-insert --opt -Q -h -u db_user -p databasename > dump.sql

Now, the following would help me with this - and only this - user:


I expected it would be possible to define several users and passwords for different hosts. Maybe by using the block multiple times? Couldn't find anything written about this.

share|improve this question
up vote 2 down vote accepted

You can do it by define another .cnf file:


and use --defaults-extra-file option:

mysqldump --defaults-extra-file=/path/to/another.cnf --complete-insert --opt -Q > dump.sql
share|improve this answer
Thx, it worked! – Leif Aug 26 '11 at 12:26

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.