< Day Day Up > |
11.3 Runtime MySQL ConfigurationBy default, the server uses built-in values for its configuration variables when it runs. If the default values aren't suitable, you can use runtime options to tell the server to use different values:
The examples in this section concentrate on options that relate to directory and file layout. Chapter 16 concentrates on performance-related options and discusses how to use them to tune the server to run more efficiently. To change the configuration and behavior of the server, specify runtime options when you start it. Options can be given on the command line or in option files (also known as configuration files). The "Core Study Guide" provides general background on the use of option files. That discussion occurs in the context of running client programs, but the bulk of it also applies to specifying server options. The server looks for option files in several standard locations. It uses any that exist, but it is not an error for an option file to be missing. The standard files are different for Windows and Unix. On Windows, the search order for option files is as follows:
WINDIR\my.ini
C:\my.cnf
WINDIR represents the location of the Windows directory. Typically, this is something like C:\Windows or C:\WinNT. On Unix, the search order includes two general option files:
/etc/my.cnf
DATADIR/my.cnf
DATADIR represents the compiled-in location of the data directory. This means that if you have two servers on the same machine, each with a different compiled-in data directory location, you can specify options specific to each server by putting them in the my.cnf file of the appropriate data directory. The Unix option file search order also includes ~/.my.cnf; that is, the .my.cnf file located in the home directory of the person running the program. However, because ~/.my.cnf is a user-specific file, it isn't an especially suitable location for server options. Normally, you invoke the server as mysql or as root with a --user=mysql option. The user-specific file that the server would read differs in the two cases, possibly leading to inconsistent sets of options being used. To name a specific option file, use a --defaults-file=file_name option on the command line In this case, the server reads only the named file and ignores the standard option files. When you use this option, it must be the first one named on the command line. To find out what options the server supports, invoke it manually with the --help option:
shell> mysqld --help
Any of the server options shown in the help message may be specified on the command line. However, it's more typical to list them in an option file, for several reasons:
To specify server startup options in an option file, use the [mysqld] option group. If the file does not exist, create it as a plain text file using an editor. To create or modify an option file, you must have write permission for it. The server itself needs only read access; it reads option files, but does not create or modify them. The following examples illustrate some ways to use option files to specify server options:
|
< Day Day Up > |