Search code examples
mysqldatabase-administration

How does mysql resolves conflict when same option is configured twice?


/etc/mysql/my.cnf

[mysqld]
option_1=val_1

!includedir /etc/mysql/conf.d/

/etc/mysql/conf.d/test.cnf

[mysqld]
option_1=val_2

As you can see the same option, in this case option_1, is defined twice . Once in the main config file and other time in the include file. My question is what will mysql treat as the final value of the option_1?

  1. val_1
  2. val_2

Solution

  • https://dev.mysql.com/doc/refman/5.7/en/option-files.html says in part:

    If multiple instances of a given option are found, the last instance takes precedence, with one exception: For mysqld, the first instance of the --user option is used as a security precaution, to prevent a user specified in an option file from being overridden on the command line.

    (emphasis mine)

    In your example, the option will be set to val_2.