Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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
share|improve this answer
    
Thx, it worked! –  Leif Aug 26 '11 at 12:26

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.