mysqlconfig

Are the hyphens (-) and underscores (_) the same in the file my.conf?


I noticed that the word separator hyphen (-) is mixed with the underscore (_) in the configuration item in the MySQL configuration file my.conf. I wonder if there is a difference between the two?

like log-bin = /var/log/mysql/mysql-bin.log

log_bin = /var/log/mysql/mysql-bin.log


Solution

  • From the official reference guide, and the section "Using Options on the Command Line":

    Within option names, dash (-) and underscore (_) may be used interchangeably in most cases [...]

    In then gives an example:

    In this Manual, we use dashes in option names, except where underscores are significant. This is the case with, for example, --log-bin and --log_bin, which are different options. We encourage you to do so as well.

    So, unless you're referring to a configuration variable where there actually is a difference between two similarly named variables (which you do in your example), you can use either - or _.

    The recommendation is to use - unless _ is necessary to avoid that exact problem of suddenly configuring something different from what you intended.