2

Using MariaDB 10.2.15 (Linux Debian Stretch)

I have created a ~/.my.cnf config file in my home directory in order to set a default database at connection time for all local client tools:

[client]
user=myuser
password=mySecretPassword
database=mydb

But I want to unset (skip) option database for a specific client program (mysqldump). This is to prevent such warning when running mysqldump:

Warning: /usr/bin/mysqldump: ignoring option '--databases' due to
invalid value 'mydb'

I was hoping using skip-OPTIONNAME in a [mysqldump] section would have worked, but unfortunately it doesn't.

[client]
user=myuser
password=mySecretPassword
database=mydb

[mysqldump]
skip-database

In fact, I noticed that database is multi-value. So overriding it is not really possible. For example, the following .my.cnf config file:

[client]
user=myuser
password=mySecretPassword
database=mydb

[mysqldump]
database=mydb2

produces 2 warnings when running mysqldump:

Warning: /usr/bin/mysqldump: ignoring option '--databases' due to
invalid value 'mydb'
Warning: /usr/bin/mysqldump: ignoring option '--databases' due to
invalid value 'mydb2'

Is there a way to "unset" option database in an overridden section?

  • Does it work/help to have a line database= in the 'mysqldump' section? – dbdemon Jun 30 '18 at 15:43
  • Thanks @dbdemon, I tried database= (empty value) but it does not help. – Nicolas Payart Jul 2 '18 at 8:09
1

In fact I am realizing that setting database option in a [client] section is may be nonsense as many client tools won't be compatible.

mysqldump and mysql_upgrade for example are complaining about this option. So I may specify it in a more specific [mysql] section instead:

[client]
user=myuser
password=mySecretPassword

[mysql]
database=mydb

Even if it meets my needs, It would still be great to find a way to override database option though...

  • Exactly the problem I had, and your solution works perfectly for mysqldump. – Kzqai Jul 24 at 0:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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