mysqldump and .my.cnf tip to avoid “ignoring option ‘–databases'” error

Don’t like how the mysqldump command keeps reading the .my.cnf and outputting the following warning/error:
mysqldump: ignoring option '--databases' due to invalid value 'dbname'

It’s been reported as a bug to mysql devs, but they keep saying it is by design, and working as intended. Here’s how you should structure the .my.cnf to avoid it:


[client]
user=user1
password=pw1
[mysql]
database=dbname

This way the “mysqldump dbname” doesn’t return that hideous error message and “mysql dbname” also works like a charm.

2 thoughts on “mysqldump and .my.cnf tip to avoid “ignoring option ‘–databases'” error”

  1. Thanks for the workaround, but that way you have to specify the db name on the mysqldump command. You have to track your db names both on .my.cnf (for ‘mysql’)and in the command lines (for ‘mysqldump’), which is not good.

    Of course the ideal solution is to add a “–database” option for mysqldump, so we can specify it in the .my.cnf for both mysqldump and mysql… but the patch seems like it wasn’t approved: http://lists.mysql.com/commits/6311

  2. thanks – just what i needed – that worked for me and now mysql and mysqldump work

    i also included a line in the client section:

    host=blah.blah.net

Leave a Comment