I compile a 5.7 MySQL database from source into a custom directory and use mysqld --initialize to initialize the database.

This works fine as long as there is no MySQL installed on the main system, or when I use mv /etc/mysql/my.cnf /etc/mysql/my.cnf_backup to get rid of the system-wide file, but of course that is a terrible workaround that breaks the system-wide mysql installation.

If a /etc/mysql/my.cnf is present, the initialization fails obviously as the paths are all wrong.

mysqld --initialize always seems to prefer /etc/mysql/my.cnf and ignores any file I specify on the command line with --defaults-file. It does however use single parameters that are specified on the command line (so it may work if I translate my complete my.cnf file into command line arguments, but that again is not a good solution and creates other problems)

Of course the whole point why I build from source into a custom directory is because I want it independent from any things that are installed on the main system.

Is there a way to let mysqld --initialize ignore /etc/mysql/my.cnf?

  • IIRC the defaults-file option has to be specified first or it will be ignored. The manual just says that it has to be first, though. dev.mysql.com/doc/refman/5.7/en/…
    – tombom
    Commented Apr 11, 2018 at 8:12
  • Wow, that was actually the problem - I would have never thought of that... - Please create an answer and I'll accept it. Commented Apr 11, 2018 at 8:22
  • Glad I could help. Answer is created.
    – tombom
    Commented Apr 11, 2018 at 8:41

1 Answer 1


The manual mentions that the --defaults-file option has to be specified first, if you want to use it.
Otherwise the option is ignored.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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