command-linemysqlmy.cnfmysqladmin

Is there a way to have .my.cnf settings for mysqladmin and mysql standard console?


My Ubuntu Linux development machine I have the following ~/.my.cnf file which is a great time saver when connecting to mysql from the command line.

[client]
auto-rehash
safe-updates
host     = localhost
user     = root
password = mysql
prompt   = "[\d]>"

However, when I type mysqladmin I receive the error

mysqladmin: unknown option '--auto-rehash'

The problem is some of the lines in the .my.cnf file aren't applicable to mysqladmin and mysqldump.

Is there a way to specify configuration options in .my.cnf such that they will apply to either mysql or mysqladmin, mysqldump or both?

If not, how do I start a mysqldump from command line and specify to it not to read the .my.cnf settings?


Solution

  • Put those options in a separate group, subject to the selected application:

    [client]
    safe-updates
    host     = localhost
    user     = root
    password = mysql
    prompt   = "[\d]>"
    
    [mysql]
    auto-rehash
    

    Read more about usage of config file on MySQL docs.