<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="option-files">
      </a>
      6.2.2.2 Using Option Files
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045324171552">
  </a>
  <a class="indexterm" name="idm46045324170480">
  </a>
  <a class="indexterm" name="idm46045324169408">
  </a>
  <a class="indexterm" name="idm46045324167920">
  </a>
  <a class="indexterm" name="idm46045324166432">
  </a>
  <a class="indexterm" name="idm46045324165360">
  </a>
  <a class="indexterm" name="idm46045324163872">
  </a>
  <a class="indexterm" name="idm46045324162784">
  </a>
  <a class="indexterm" name="idm46045324161296">
  </a>
  <a class="indexterm" name="idm46045324160208">
  </a>
  <p>
   Most MySQL programs can read startup options from option files
        (sometimes called configuration files). Option files provide a
        convenient way to specify commonly used options so that they
        need not be entered on the command line each time you run a
        program.
  </p>
  <p>
   To determine whether a program reads option files, invoke it
        with the
   <code class="option">
    --help
   </code>
   option. (For
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   , use
   <a class="link" href="server-options.html#option_mysqld_verbose">
    <code class="option">
     --verbose
    </code>
   </a>
   and
   <a class="link" href="server-options.html#option_mysqld_help">
    <code class="option">
     --help
    </code>
   </a>
   .) If the program reads
        option files, the help message indicates which files it looks
        for and which option groups it recognizes.
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    A MySQL program started with the
    <code class="option">
     --no-defaults
    </code>
    option reads no option files
          other than
    <code class="filename">
     .mylogin.cnf
    </code>
    .
   </p>
   <p>
    A server started with the
    <a class="link" href="server-system-variables.html#sysvar_persisted_globals_load">
     <code class="literal">
      persisted_globals_load
     </code>
    </a>
    system
          variable disabled does not read
    <code class="filename">
     mysqld-auto.cnf
    </code>
    .
   </p>
  </div>
  <p>
   Many option files are plain text files, created using any text
        editor. The exceptions are:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      The
      <code class="filename">
       .mylogin.cnf
      </code>
      file that contains
            login path options. This is an encrypted file created by the
      <a class="link" href="mysql-config-editor.html" title="6.6.7 mysql_config_editor — MySQL Configuration Utility">
       <span class="command">
        <strong>
         mysql_config_editor
        </strong>
       </span>
      </a>
      utility. See
      <a class="xref" href="mysql-config-editor.html" title="6.6.7 mysql_config_editor — MySQL Configuration Utility">
       Section 6.6.7, “mysql_config_editor — MySQL Configuration Utility”
      </a>
      . A
      <span class="quote">
       “
       <span class="quote">
        login
            path
       </span>
       ”
      </span>
      is an option group that permits only certain
            options:
      <code class="option">
       host
      </code>
      ,
      <code class="option">
       user
      </code>
      ,
      <code class="option">
       password
      </code>
      ,
      <code class="option">
       port
      </code>
      and
      <code class="option">
       socket
      </code>
      . Client programs specify which login
            path to read from
      <code class="filename">
       .mylogin.cnf
      </code>
      using
            the
      <a class="link" href="option-file-options.html#option_general_login-path">
       <code class="option">
        --login-path
       </code>
      </a>
      option.
     </p>
     <p>
      To specify an alternative login path file name, set the
      <code class="literal">
       MYSQL_TEST_LOGIN_FILE
      </code>
      environment
            variable. This variable is used by the
      <span class="command">
       <strong>
        mysql-test-run.pl
       </strong>
      </span>
      testing utility, but
            also is recognized by
      <a class="link" href="mysql-config-editor.html" title="6.6.7 mysql_config_editor — MySQL Configuration Utility">
       <span class="command">
        <strong>
         mysql_config_editor
        </strong>
       </span>
      </a>
      and by MySQL clients such as
      <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
       <span class="command">
        <strong>
         mysql
        </strong>
       </span>
      </a>
      ,
      <a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
       <span class="command">
        <strong>
         mysqladmin
        </strong>
       </span>
      </a>
      , and so forth.
     </p>
    </li>
    <li class="listitem">
     <p>
      The
      <code class="filename">
       mysqld-auto.cnf
      </code>
      file in the data
            directory. This JSON-format file contains persisted system
            variable settings. It is created by the server upon
            execution of
      <a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
       <code class="literal">
        SET
            PERSIST
       </code>
      </a>
      or
      <a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
       <code class="literal">
        SET
            PERSIST_ONLY
       </code>
      </a>
      statements. See
      <a class="xref" href="persisted-system-variables.html" title="7.1.9.3 Persisted System Variables">
       Section 7.1.9.3, “Persisted System Variables”
      </a>
      . Management of
      <code class="filename">
       mysqld-auto.cnf
      </code>
      should be left to the
            server and not performed manually.
     </p>
    </li>
   </ul>
  </div>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="xref" href="option-files.html#option-file-order" title="Option File Processing Order">
       Option File Processing Order
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="option-files.html#option-file-syntax" title="Option File Syntax">
       Option File Syntax
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="option-files.html#option-file-inclusions" title="Option File Inclusions">
       Option File Inclusions
      </a>
     </p>
    </li>
   </ul>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h5 class="title">
       <a name="option-file-order">
       </a>
       Option File Processing Order
      </h5>
     </div>
    </div>
   </div>
   <p>
    MySQL looks for option files in the order described in the
          following discussion and reads any that exist. If an option
          file you want to use does not exist, create it using the
          appropriate method, as just discussed.
   </p>
   <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
    <div class="admon-title">
     Note
    </div>
    <p>
     For information about option files used with NDB Cluster
            programs, see
     <a class="xref" href="mysql-cluster-configuration.html" title="25.4 Configuration of NDB Cluster">
      Section 25.4, “Configuration of NDB Cluster”
     </a>
     .
    </p>
   </div>
   <p>
    On Windows, MySQL programs read startup options from the files
          shown in the following table, in the specified order (files
          listed first are read first, files read later take
          precedence).
   </p>
   <div class="table">
    <a name="option-files-windows">
    </a>
    <p class="title">
     <b>
      Table 6.1 Option Files Read on Windows Systems
     </b>
    </p>
    <div class="table-contents">
     <table summary="Option files read by MySQL programs on Windows systems.">
      <colgroup>
       <col style="width: 30%"/>
       <col style="width: 70%"/>
      </colgroup>
      <thead>
       <tr>
        <th>
         File Name
        </th>
        <th>
         Purpose
        </th>
       </tr>
      </thead>
      <tbody>
       <tr>
        <td>
         <code class="filename">
          <code class="literal">
           %WINDIR%
          </code>
          \my.ini
         </code>
         ,
         <code class="filename">
          <code class="literal">
           %WINDIR%
          </code>
          \my.cnf
         </code>
        </td>
        <td>
         Global options
        </td>
       </tr>
       <tr>
        <td>
         <code class="filename">
          C:\my.ini
         </code>
         ,
         <code class="filename">
          C:\my.cnf
         </code>
        </td>
        <td>
         Global options
        </td>
       </tr>
       <tr>
        <td>
         <code class="filename">
          <em class="replaceable">
           <code>
            BASEDIR
           </code>
          </em>
          \my.ini
         </code>
         ,
         <code class="filename">
          <em class="replaceable">
           <code>
            BASEDIR
           </code>
          </em>
          \my.cnf
         </code>
        </td>
        <td>
         Global options
        </td>
       </tr>
       <tr>
        <td>
         <code class="literal">
          defaults-extra-file
         </code>
        </td>
        <td>
         The file specified with
         <a class="link" href="option-file-options.html#option_general_defaults-extra-file">
          <code class="option">
           --defaults-extra-file
          </code>
         </a>
         ,
                if any
        </td>
       </tr>
       <tr>
        <td>
         <code class="filename">
          <code class="literal">
           %APPDATA%
          </code>
          \MySQL\.mylogin.cnf
         </code>
        </td>
        <td>
         Login path options (clients only)
        </td>
       </tr>
       <tr>
        <td>
         <code class="filename">
          <em class="replaceable">
           <code>
            DATADIR
           </code>
          </em>
          \mysqld-auto.cnf
         </code>
        </td>
        <td>
         System variables persisted with
         <a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
          <code class="literal">
           SET
                PERSIST
          </code>
         </a>
         or
         <a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
          <code class="literal">
           SET
                PERSIST_ONLY
          </code>
         </a>
         (server only)
        </td>
       </tr>
      </tbody>
     </table>
    </div>
   </div>
   <br class="table-break"/>
   <p>
    In the preceding table,
    <code class="literal">
     %WINDIR%
    </code>
    represents
          the location of your Windows directory. This is commonly
    <code class="filename">
     C:\WINDOWS
    </code>
    . Use the following command to
          determine its exact location from the value of the
    <code class="literal">
     WINDIR
    </code>
    environment variable:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa56669563"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">C:\&gt;</span><span class="token command"> echo</span> %WINDIR%</code></pre>
   </div>
   <p>
    <code class="literal">
     %APPDATA%
    </code>
    represents the value of the
          Windows application data directory. Use the following command
          to determine its exact location from the value of the
    <code class="literal">
     APPDATA
    </code>
    environment variable:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa44855089"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">C:\&gt;</span><span class="token command"> echo</span> %APPDATA%</code></pre>
   </div>
   <p>
    <em class="replaceable">
     <code>
      BASEDIR
     </code>
    </em>
    represents the MySQL base
          installation directory. When MySQL 8.4 has been
          installed using the MSI, this is typically
    <code class="filename">
     C:\
     <em class="replaceable">
      <code>
       PROGRAMDIR
      </code>
     </em>
     \MySQL\MySQL
          Server 8.4
    </code>
    in which
    <em class="replaceable">
     <code>
      PROGRAMDIR
     </code>
    </em>
    represents the programs
          directory (usually
    <code class="filename">
     Program Files
    </code>
    for
          English-language versions of Windows).
   </p>
   <div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
    <div class="admon-title">
     Important
    </div>
    <p>
     Although MySQL Configurator places most files under
     <em class="replaceable">
      <code>
       PROGRAMDIR
      </code>
     </em>
     , it installs
     <code class="filename">
      my.ini
     </code>
     under the
     <code class="filename">
      C:\ProgramData\MySQL\MySQL Server
            8.4\
     </code>
     directory by default.
    </p>
   </div>
   <p>
    <em class="replaceable">
     <code>
      DATADIR
     </code>
    </em>
    represents the MySQL data
          directory. As used to find
    <code class="filename">
     mysqld-auto.cnf
    </code>
    , its default value is the
          data directory location built in when MySQL was compiled, but
          can be changed by
    <a class="link" href="server-system-variables.html#sysvar_datadir">
     <code class="option">
      --datadir
     </code>
    </a>
    specified as an option-file or command-line option processed
          before
    <code class="filename">
     mysqld-auto.cnf
    </code>
    is processed.
   </p>
   <p>
    On Unix and Unix-like systems, MySQL programs read startup
          options from the files shown in the following table, in the
          specified order (files listed first are read first, files read
          later take precedence).
   </p>
   <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
    <div class="admon-title">
     Note
    </div>
    <p>
     On Unix platforms, MySQL ignores configuration files that
            are world-writable. This is intentional as a security
            measure.
    </p>
   </div>
   <a class="indexterm" name="idm46045324071648">
   </a>
   <a class="indexterm" name="idm46045324070576">
   </a>
   <div class="table">
    <a name="option-files-unix">
    </a>
    <p class="title">
     <b>
      Table 6.2 Option Files Read on Unix and Unix-Like Systems
     </b>
    </p>
    <div class="table-contents">
     <table summary="Option files read by MySQL programs on Unix and Unix-like systems.">
      <colgroup>
       <col style="width: 30%"/>
       <col style="width: 70%"/>
      </colgroup>
      <thead>
       <tr>
        <th>
         File Name
        </th>
        <th>
         Purpose
        </th>
       </tr>
      </thead>
      <tbody>
       <tr>
        <td>
         <code class="filename">
          /etc/my.cnf
         </code>
        </td>
        <td>
         Global options
        </td>
       </tr>
       <tr>
        <td>
         <code class="filename">
          /etc/mysql/my.cnf
         </code>
        </td>
        <td>
         Global options
        </td>
       </tr>
       <tr>
        <td>
         <code class="filename">
          <em class="replaceable">
           <code>
            SYSCONFDIR
           </code>
          </em>
          /my.cnf
         </code>
        </td>
        <td>
         Global options
        </td>
       </tr>
       <tr>
        <td>
         <code class="filename">
          $MYSQL_HOME/my.cnf
         </code>
        </td>
        <td>
         Server-specific options (server only)
        </td>
       </tr>
       <tr>
        <td>
         <code class="literal">
          defaults-extra-file
         </code>
        </td>
        <td>
         The file specified with
         <a class="link" href="option-file-options.html#option_general_defaults-extra-file">
          <code class="option">
           --defaults-extra-file
          </code>
         </a>
         ,
                if any
        </td>
       </tr>
       <tr>
        <td>
         <code class="filename">
          ~/.my.cnf
         </code>
        </td>
        <td>
         User-specific options
        </td>
       </tr>
       <tr>
        <td>
         <code class="filename">
          ~/.mylogin.cnf
         </code>
        </td>
        <td>
         User-specific login path options (clients only)
        </td>
       </tr>
       <tr>
        <td>
         <code class="filename">
          <em class="replaceable">
           <code>
            DATADIR
           </code>
          </em>
          /mysqld-auto.cnf
         </code>
        </td>
        <td>
         System variables persisted with
         <a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
          <code class="literal">
           SET
                PERSIST
          </code>
         </a>
         or
         <a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
          <code class="literal">
           SET
                PERSIST_ONLY
          </code>
         </a>
         (server only)
        </td>
       </tr>
      </tbody>
     </table>
    </div>
   </div>
   <br class="table-break"/>
   <p>
    In the preceding table,
    <code class="filename">
     ~
    </code>
    represents the
          current user's home directory (the value of
    <code class="literal">
     $HOME
    </code>
    ).
   </p>
   <p>
    <em class="replaceable">
     <code>
      SYSCONFDIR
     </code>
    </em>
    represents the directory
          specified with the
    <a class="link" href="source-configuration-options.html#option_cmake_sysconfdir">
     <code class="option">
      SYSCONFDIR
     </code>
    </a>
    option to
    <span class="command">
     <strong>
      CMake
     </strong>
    </span>
    when MySQL was built. By
          default, this is the
    <code class="filename">
     etc
    </code>
    directory
          located under the compiled-in installation directory.
   </p>
   <p>
    <code class="literal">
     MYSQL_HOME
    </code>
    is an environment variable
          containing the path to the directory in which the
          server-specific
    <code class="filename">
     my.cnf
    </code>
    file resides. If
    <code class="literal">
     MYSQL_HOME
    </code>
    is not set and you start the
          server using the
    <a class="link" href="mysqld-safe.html" title="6.3.2 mysqld_safe — MySQL Server Startup Script">
     <span class="command">
      <strong>
       mysqld_safe
      </strong>
     </span>
    </a>
    program,
    <a class="link" href="mysqld-safe.html" title="6.3.2 mysqld_safe — MySQL Server Startup Script">
     <span class="command">
      <strong>
       mysqld_safe
      </strong>
     </span>
    </a>
    sets it to
    <em class="replaceable">
     <code>
      BASEDIR
     </code>
    </em>
    , the MySQL base
          installation directory.
   </p>
   <p>
    <em class="replaceable">
     <code>
      DATADIR
     </code>
    </em>
    represents the MySQL data
          directory. As used to find
    <code class="filename">
     mysqld-auto.cnf
    </code>
    , its default value is the
          data directory location built in when MySQL was compiled, but
          can be changed by
    <a class="link" href="server-system-variables.html#sysvar_datadir">
     <code class="option">
      --datadir
     </code>
    </a>
    specified as an option-file or command-line option processed
          before
    <code class="filename">
     mysqld-auto.cnf
    </code>
    is processed.
   </p>
   <p>
    If multiple instances of a given option are found, the last
          instance takes precedence, with one exception: For
    <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
     <span class="command">
      <strong>
       mysqld
      </strong>
     </span>
    </a>
    , the
    <span class="emphasis">
     <em>
      first
     </em>
    </span>
    instance of the
    <a class="link" href="server-options.html#option_mysqld_user">
     <code class="option">
      --user
     </code>
    </a>
    option
          is used as a security precaution, to prevent a user specified
          in an option file from being overridden on the command line.
   </p>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h5 class="title">
       <a name="option-file-syntax">
       </a>
       Option File Syntax
      </h5>
     </div>
    </div>
   </div>
   <p>
    The following description of option file syntax applies to
          files that you edit manually. This excludes
    <code class="filename">
     .mylogin.cnf
    </code>
    , which is created using
    <a class="link" href="mysql-config-editor.html" title="6.6.7 mysql_config_editor — MySQL Configuration Utility">
     <span class="command">
      <strong>
       mysql_config_editor
      </strong>
     </span>
    </a>
    and is encrypted, and
    <code class="filename">
     mysqld-auto.cnf
    </code>
    , which the server creates
          in JSON format.
   </p>
   <p>
    Any long option that may be given on the command line when
          running a MySQL program can be given in an option file as
          well. To get the list of available options for a program, run
          it with the
    <code class="option">
     --help
    </code>
    option. (For
    <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
     <span class="command">
      <strong>
       mysqld
      </strong>
     </span>
    </a>
    , use
    <a class="link" href="server-options.html#option_mysqld_verbose">
     <code class="option">
      --verbose
     </code>
    </a>
    and
    <a class="link" href="server-options.html#option_mysqld_help">
     <code class="option">
      --help
     </code>
    </a>
    .)
   </p>
   <p>
    The syntax for specifying options in an option file is similar
          to command-line syntax (see
    <a class="xref" href="command-line-options.html" title="6.2.2.1 Using Options on the Command Line">
     Section 6.2.2.1, “Using Options on the Command Line”
    </a>
    ). However, in an option
          file, you omit the leading two dashes from the option name and
          you specify only one option per line. For example,
    <code class="option">
     --quick
    </code>
    and
    <code class="option">
     --host=localhost
    </code>
    on the command line should be specified as
    <code class="literal">
     quick
    </code>
    and
    <code class="literal">
     host=localhost
    </code>
    on separate lines in an option file. To specify an option of
          the form
    <code class="option">
     --loose-
     <em class="replaceable">
      <code>
       opt_name
      </code>
     </em>
    </code>
    in an option file, write it as
    <code class="literal">
     loose-
     <em class="replaceable">
      <code>
       opt_name
      </code>
     </em>
    </code>
    .
   </p>
   <p>
    Empty lines in option files are ignored. Nonempty lines can
          take any of the following forms:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       <code class="literal">
        #
        <em class="replaceable">
         <code>
          comment
         </code>
        </em>
       </code>
       ,
       <code class="literal">
        ;
        <em class="replaceable">
         <code>
          comment
         </code>
        </em>
       </code>
      </p>
      <p>
       Comment lines start with
       <code class="literal">
        #
       </code>
       or
       <code class="literal">
        ;
       </code>
       . A
       <code class="literal">
        #
       </code>
       comment can
              start in the middle of a line as well.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        [
        <em class="replaceable">
         <code>
          group
         </code>
        </em>
        ]
       </code>
      </p>
      <p>
       <em class="replaceable">
        <code>
         group
        </code>
       </em>
       is the name of the
              program or group for which you want to set options. After
              a group line, any option-setting lines apply to the named
              group until the end of the option file or another group
              line is given. Option group names are not case-sensitive.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        <em class="replaceable">
         <code>
          opt_name
         </code>
        </em>
       </code>
      </p>
      <p>
       This is equivalent to
       <code class="option">
        --
        <em class="replaceable">
         <code>
          opt_name
         </code>
        </em>
       </code>
       on
              the command line.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        <em class="replaceable">
         <code>
          opt_name
         </code>
        </em>
        =
        <em class="replaceable">
         <code>
          value
         </code>
        </em>
       </code>
      </p>
      <p>
       This is equivalent to
       <code class="option">
        --
        <em class="replaceable">
         <code>
          opt_name
         </code>
        </em>
        =
        <em class="replaceable">
         <code>
          value
         </code>
        </em>
       </code>
       on the command line. In an option file, you can have
              spaces around the
       <code class="literal">
        =
       </code>
       character,
              something that is not true on the command line. The value
              optionally can be enclosed within single quotation marks
              or double quotation marks, which is useful if the value
              contains a
       <code class="literal">
        #
       </code>
       comment character.
      </p>
     </li>
    </ul>
   </div>
   <p>
    Leading and trailing spaces are automatically deleted from
          option names and values.
   </p>
   <a class="indexterm" name="idm46045323988176">
   </a>
   <a class="indexterm" name="idm46045323986688">
   </a>
   <p>
    You can use the escape sequences
    <code class="literal">
     \b
    </code>
    ,
    <code class="literal">
     \t
    </code>
    ,
    <code class="literal">
     \n
    </code>
    ,
    <code class="literal">
     \r
    </code>
    ,
    <code class="literal">
     \\
    </code>
    , and
    <code class="literal">
     \s
    </code>
    in option values to represent the
          backspace, tab, newline, carriage return, backslash, and space
          characters. In option files, these escaping rules apply:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       A backslash followed by a valid escape sequence character
              is converted to the character represented by the sequence.
              For example,
       <code class="literal">
        \s
       </code>
       is converted to a
              space.
      </p>
     </li>
     <li class="listitem">
      <p>
       A backslash not followed by a valid escape sequence
              character remains unchanged. For example,
       <code class="literal">
        \S
       </code>
       is retained as is.
      </p>
     </li>
    </ul>
   </div>
   <p>
    The preceding rules mean that a literal backslash can be given
          as
    <code class="literal">
     \\
    </code>
    , or as
    <code class="literal">
     \
    </code>
    if it is
          not followed by a valid escape sequence character.
   </p>
   <p>
    The rules for escape sequences in option files differ slightly
          from the rules for escape sequences in string literals in SQL
          statements. In the latter context, if
    <span class="quote">
     “
     <span class="quote">
      <em class="replaceable">
       <code>
        x
       </code>
      </em>
     </span>
     ”
    </span>
    is not a valid
          escape sequence character,
    <code class="literal">
     \
     <em class="replaceable">
      <code>
       x
      </code>
     </em>
    </code>
    becomes
    <span class="quote">
     “
     <span class="quote">
      <em class="replaceable">
       <code>
        x
       </code>
      </em>
     </span>
     ”
    </span>
    rather than
    <code class="literal">
     \
     <em class="replaceable">
      <code>
       x
      </code>
     </em>
    </code>
    . See
    <a class="xref" href="string-literals.html" title="11.1.1 String Literals">
     Section 11.1.1, “String Literals”
    </a>
    .
   </p>
   <a class="indexterm" name="idm46045323970144">
   </a>
   <a class="indexterm" name="idm46045323968656">
   </a>
   <p>
    The escaping rules for option file values are especially
          pertinent for Windows path names, which use
    <code class="literal">
     \
    </code>
    as a path name separator. A separator in
          a Windows path name must be written as
    <code class="literal">
     \\
    </code>
    if it is followed by an escape sequence character. It can be
          written as
    <code class="literal">
     \\
    </code>
    or
    <code class="literal">
     \
    </code>
    if it
          is not. Alternatively,
    <code class="literal">
     /
    </code>
    may be used in
          Windows path names and is treated as
    <code class="literal">
     \
    </code>
    .
          Suppose that you want to specify a base directory of
    <code class="filename">
     C:\Program Files\MySQL\MySQL Server
          8.4
    </code>
    in an option file. This can be
          done several ways. Some examples:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa67645995"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token constant">basedir</span><span class="token attr-value"><span class="token punctuation">=</span>"C:\Program Files\MySQL\MySQL Server 8.4"</span>
<span class="token constant">basedir</span><span class="token attr-value"><span class="token punctuation">=</span>"C:\\Program Files\\MySQL\\MySQL Server 8.4"</span>
<span class="token constant">basedir</span><span class="token attr-value"><span class="token punctuation">=</span>"C:/Program Files/MySQL/MySQL Server 8.4"</span>
<span class="token constant">basedir</span><span class="token attr-value"><span class="token punctuation">=</span>C:\\Program\sFiles\\MySQL\\MySQL\sServer\s8.4</span></code></pre>
   </div>
   <p>
    If an option group name is the same as a program name, options
          in the group apply specifically to that program. For example,
          the
    <code class="literal">
     [mysqld]
    </code>
    and
    <code class="literal">
     [mysql]
    </code>
    groups apply to the
    <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
     <span class="command">
      <strong>
       mysqld
      </strong>
     </span>
    </a>
    server and the
    <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
     <span class="command">
      <strong>
       mysql
      </strong>
     </span>
    </a>
    client program, respectively.
   </p>
   <p>
    The
    <code class="literal">
     [client]
    </code>
    option group is read by all
          client programs provided in MySQL distributions (but
    <span class="emphasis">
     <em>
      not
     </em>
    </span>
    by
    <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
     <span class="command">
      <strong>
       mysqld
      </strong>
     </span>
    </a>
    ). To
          understand how third-party client programs that use the C API
          can use option files, see the C API documentation at
    <a class="ulink" href="/doc/c-api/8.4/en/mysql-options.html" target="_top">
     mysql_options()
    </a>
    .
   </p>
   <p>
    The
    <code class="literal">
     [client]
    </code>
    group enables you to specify
          options that apply to all clients. For example,
    <code class="literal">
     [client]
    </code>
    is the appropriate group to use to
          specify the password for connecting to the server. (But make
          sure that the option file is accessible only by yourself, so
          that other people cannot discover your password.) Be sure not
          to put an option in the
    <code class="literal">
     [client]
    </code>
    group
          unless it is recognized by
    <span class="emphasis">
     <em>
      all
     </em>
    </span>
    client
          programs that you use. Programs that do not understand the
          option quit after displaying an error message if you try to
          run them.
   </p>
   <p>
    List more general option groups first and more specific groups
          later. For example, a
    <code class="literal">
     [client]
    </code>
    group is
          more general because it is read by all client programs,
          whereas a
    <code class="literal">
     [mysqldump]
    </code>
    group is read only by
    <a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
     <span class="command">
      <strong>
       mysqldump
      </strong>
     </span>
    </a>
    . Options specified later override
          options specified earlier, so putting the option groups in the
          order
    <code class="literal">
     [client]
    </code>
    ,
    <code class="literal">
     [mysqldump]
    </code>
    enables
    <a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
     <span class="command">
      <strong>
       mysqldump
      </strong>
     </span>
    </a>
    -specific options to override
    <code class="literal">
     [client]
    </code>
    options.
   </p>
   <p>
    Here is a typical global option file:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa23520600"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[client]</span>
<span class="token constant">port</span><span class="token attr-value"><span class="token punctuation">=</span>3306</span>
<span class="token constant">socket</span><span class="token attr-value"><span class="token punctuation">=</span>/tmp/mysql.sock</span>

<span class="token selector">[mysqld]</span>
<span class="token constant">port</span><span class="token attr-value"><span class="token punctuation">=</span>3306</span>
<span class="token constant">socket</span><span class="token attr-value"><span class="token punctuation">=</span>/tmp/mysql.sock</span>
<span class="token constant">key_buffer_size</span><span class="token attr-value"><span class="token punctuation">=</span>16M</span>
<span class="token constant">max_allowed_packet</span><span class="token attr-value"><span class="token punctuation">=</span>128M</span>

<span class="token selector">[mysqldump]</span>
<span class="token constant">quick</span></code></pre>
   </div>
   <p>
    Here is a typical user option file:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa63509956"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[client]</span>
<span class="token comment" spellcheck="true"># The following password is sent to all standard MySQL clients</span>
<span class="token constant">password</span><span class="token attr-value"><span class="token punctuation">=</span>"my password"</span>

<span class="token selector">[mysql]</span>
<span class="token constant">no-auto-rehash</span>
<span class="token constant">connect_timeout</span><span class="token attr-value"><span class="token punctuation">=</span>2</span></code></pre>
   </div>
   <p>
    To create option groups to be read only by
    <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
     <span class="command">
      <strong>
       mysqld
      </strong>
     </span>
    </a>
    servers from specific MySQL release
          series, use groups with names of
    <code class="literal">
     [mysqld-8.3]
    </code>
    ,
    <code class="literal">
     [mysqld-8.4]
    </code>
    , and so forth.
          The following group indicates that the
    <a class="link" href="server-system-variables.html#sysvar_sql_mode">
     <code class="literal">
      sql_mode
     </code>
    </a>
    setting should be
          used only by MySQL servers with 8.4.x version
          numbers:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa96218377"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld-8.4]</span>
<span class="token constant">sql_mode</span><span class="token attr-value"><span class="token punctuation">=</span>TRADITIONAL</span></code></pre>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h5 class="title">
       <a name="option-file-inclusions">
       </a>
       Option File Inclusions
      </h5>
     </div>
    </div>
   </div>
   <p>
    It is possible to use
    <code class="literal">
     !include
    </code>
    directives
          in option files to include other option files and
    <code class="literal">
     !includedir
    </code>
    to search specific directories
          for option files. For example, to include the
    <code class="filename">
     /home/mydir/myopt.cnf
    </code>
    file, use the
          following directive:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-ini"><div class="docs-select-all right" id="sa11487548"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini">!include /home/mydir/myopt.cnf</code></pre>
   </div>
   <p>
    To search the
    <code class="filename">
     /home/mydir
    </code>
    directory and
          read option files found there, use this directive:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-ini"><div class="docs-select-all right" id="sa69297318"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini">!includedir /home/mydir</code></pre>
   </div>
   <p>
    MySQL makes no guarantee about the order in which option files
          in the directory are read.
   </p>
   <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
    <div class="admon-title">
     Note
    </div>
    <p>
     Any files to be found and included using the
     <code class="literal">
      !includedir
     </code>
     directive on Unix operating
            systems
     <span class="emphasis">
      <em>
       must
      </em>
     </span>
     have file names ending in
     <code class="filename">
      .cnf
     </code>
     . On Windows, this directive checks
            for files with the
     <code class="filename">
      .ini
     </code>
     or
     <code class="filename">
      .cnf
     </code>
     extension.
    </p>
   </div>
   <p>
    Write the contents of an included option file like any other
          option file. That is, it should contain groups of options,
          each preceded by a
    <code class="literal">
     [
     <em class="replaceable">
      <code>
       group
      </code>
     </em>
     ]
    </code>
    line
          that indicates the program to which the options apply.
   </p>
   <p>
    While an included file is being processed, only those options
          in groups that the current program is looking for are used.
          Other groups are ignored. Suppose that a
    <code class="filename">
     my.cnf
    </code>
    file contains this line:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-ini"><div class="docs-select-all right" id="sa70626475"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini">!include /home/mydir/myopt.cnf</code></pre>
   </div>
   <p>
    And suppose that
    <code class="filename">
     /home/mydir/myopt.cnf
    </code>
    looks like this:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa39867180"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqladmin]</span>
<span class="token constant">force</span>

<span class="token selector">[mysqld]</span>
<span class="token constant">key_buffer_size</span><span class="token attr-value"><span class="token punctuation">=</span>16M</span></code></pre>
   </div>
   <p>
    If
    <code class="filename">
     my.cnf
    </code>
    is processed by
    <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
     <span class="command">
      <strong>
       mysqld
      </strong>
     </span>
    </a>
    , only the
    <code class="literal">
     [mysqld]
    </code>
    group in
    <code class="filename">
     /home/mydir/myopt.cnf
    </code>
    is used. If the
          file is processed by
    <a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
     <span class="command">
      <strong>
       mysqladmin
      </strong>
     </span>
    </a>
    , only the
    <code class="literal">
     [mysqladmin]
    </code>
    group is used. If the file is
          processed by any other program, no options in
    <code class="filename">
     /home/mydir/myopt.cnf
    </code>
    are used.
   </p>
   <p>
    The
    <code class="literal">
     !includedir
    </code>
    directive is processed
          similarly except that all option files in the named directory
          are read.
   </p>
   <p>
    If an option file contains
    <code class="literal">
     !include
    </code>
    or
    <code class="literal">
     !includedir
    </code>
    directives, files named by
          those directives are processed whenever the option file is
          processed, no matter where they appear in the file.
   </p>
   <p>
    For inclusion directives to work, the file path should not be
          specified within quotes and should have no escape sequences.
          For example, the following statements provided in
    <code class="filename">
     my.ini
    </code>
    read the option file
    <code class="filename">
     myopts.ini
    </code>
    :
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa23714900"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini">!include C:/ProgramData/MySQL/MySQL Server/myopts.ini
!include C:\ProgramData\MySQL\MySQL Server\myopts.ini
!include C:\\ProgramData\\MySQL\\MySQL Server\\myopts.ini</code></pre>
   </div>
   <p>
    On Windows, if
    <code class="literal">
     !include
     <em class="replaceable">
      <code>
       /path/to/extra.ini
      </code>
     </em>
    </code>
    is the
          last line in the file, make sure that a newline is appended at
          the end; otherwise, the line is ignored.
   </p>
  </div>
 </div>
 <br/>
</div>
