Mariadb – Override database option in a user-specific .the.cnf config file

mariadbmy.cnf

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?

Best Answer

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...