Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like to find out under which section of the MySQL configuration file variables can be used. For instance I can place bind-address under [mysqld] or [server] which works, but it doesn't work when placed under [client]. When I lookup the documentation, all I get is this:

Command-Line Format --bind-address=addr
Option-File Format  bind-address=addr
Variable Name       bind-address
Variable Scope      Global
Dynamic Variable    No
                    Permitted Values
                    Type    string
                    Default 0.0.0.0

It tells me that the scope is Global, but not where I should place it. I'm cleaning up a my.cnf file with many variables that are placed under different sections and I just have no idea what should go where.

Is there a way I can find out which section of the MySQL configuration a variable be placed under?

share|improve this question
add comment

1 Answer

Basically my.cnf is a configuration file for multiple aspects of MySQL, including the Daemon/Server, the client, the safe mode versions of each, etc.

Some programs grab configuration directives from multiple groups.

So for example, the bind-address directive is only relevant to the daemon/server because it is the only thing which needs to bind itself to an address, as such that directive only belongs in the [mysqld] or [server] sections. When you start the server it does not look at anything in the [client] section, and when you start the client the bind-address directive is not relevant.

The reason why the documentation tells you that the my.cnf scope is global is because it is, all programs in the MySQL suite can/will look in that file for options.

So if you think of it less as "sections" of the config and more as multiple configuration files in one, it might make a bit more sense. When deciding what to put where you simply need to think about what aspect of mysql are you trying to set options for. The server? The client? Safe-mode only?

So to answer your question in summary form, "What should go where?" - Put options relevant to certain programs in the section which applies to that program.

mysql --help

Default options are read from the following files in the given order: /etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf The following groups are read: mysql client

For some futher reading:

MySQL Server Options (and the sections you can use to set them)

Using MySQL Options Files (overview on my.cnf)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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