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.

Example:

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

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

[mysqldump]
host=example.com
user=db_user
password=password

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.

link|improve this question
feedback

1 Answer

up vote 2 down vote accepted

You can do it by define another .cnf file:

[mysqldump]
host=example2.com
user=db_user2
password=password2

and use --defaults-extra-file option:

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

Your Answer

 
or
required, but never shown

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