<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h2 class="title">
      <a name="environment-variables">
      </a>
      6.9 Environment Variables
     </h2>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045302818864">
  </a>
  <a class="indexterm" name="idm46045302817376">
  </a>
  <a class="indexterm" name="idm46045302816304">
  </a>
  <p>
   This section lists environment variables that are used directly or
    indirectly by MySQL. Most of these can also be found in other places
    in this manual.
  </p>
  <p>
   Options on the command line take precedence over values specified in
    option files and environment variables, and values in option files
    take precedence over values in environment variables. In many cases,
    it is preferable to use an option file instead of environment
    variables to modify the behavior of MySQL. See
   <a class="xref" href="option-files.html" title="6.2.2.2 Using Option Files">
    Section 6.2.2.2, “Using Option Files”
   </a>
   .
  </p>
  <a class="indexterm" name="idm46045302813264">
  </a>
  <a class="indexterm" name="idm46045302812160">
  </a>
  <a class="indexterm" name="idm46045302810656">
  </a>
  <a class="indexterm" name="idm46045302809552">
  </a>
  <a class="indexterm" name="idm46045302808048">
  </a>
  <a class="indexterm" name="idm46045302806944">
  </a>
  <a class="indexterm" name="idm46045302805456">
  </a>
  <a class="indexterm" name="idm46045302804368">
  </a>
  <a class="indexterm" name="idm46045302802912">
  </a>
  <a class="indexterm" name="idm46045302801840">
  </a>
  <a class="indexterm" name="idm46045302800384">
  </a>
  <a class="indexterm" name="idm46045302799296">
  </a>
  <a class="indexterm" name="idm46045302797808">
  </a>
  <a class="indexterm" name="idm46045302796720">
  </a>
  <a class="indexterm" name="idm46045302795232">
  </a>
  <a class="indexterm" name="idm46045302794144">
  </a>
  <a class="indexterm" name="idm46045302792656">
  </a>
  <a class="indexterm" name="idm46045302791568">
  </a>
  <a class="indexterm" name="idm46045302790080">
  </a>
  <a class="indexterm" name="idm46045302788976">
  </a>
  <a class="indexterm" name="idm46045302787472">
  </a>
  <a class="indexterm" name="idm46045302786368">
  </a>
  <a class="indexterm" name="idm46045302784880">
  </a>
  <a class="indexterm" name="idm46045302783792">
  </a>
  <a class="indexterm" name="idm46045302782304">
  </a>
  <a class="indexterm" name="idm46045302781216">
  </a>
  <a class="indexterm" name="idm46045302779728">
  </a>
  <a class="indexterm" name="idm46045302778640">
  </a>
  <a class="indexterm" name="idm46045302777152">
  </a>
  <a class="indexterm" name="idm46045302776064">
  </a>
  <a class="indexterm" name="idm46045302774576">
  </a>
  <a class="indexterm" name="idm46045302773488">
  </a>
  <a class="indexterm" name="idm46045302772000">
  </a>
  <a class="indexterm" name="idm46045302770912">
  </a>
  <a class="indexterm" name="idm46045302769424">
  </a>
  <a class="indexterm" name="idm46045302768336">
  </a>
  <a class="indexterm" name="idm46045302766848">
  </a>
  <a class="indexterm" name="idm46045302765760">
  </a>
  <a class="indexterm" name="idm46045302764272">
  </a>
  <a class="indexterm" name="idm46045302763184">
  </a>
  <a class="indexterm" name="idm46045302761696">
  </a>
  <a class="indexterm" name="idm46045302760608">
  </a>
  <a class="indexterm" name="idm46045302759120">
  </a>
  <a class="indexterm" name="idm46045302758016">
  </a>
  <a class="indexterm" name="idm46045302756528">
  </a>
  <a class="indexterm" name="idm46045302755424">
  </a>
  <a class="indexterm" name="idm46045302753936">
  </a>
  <a class="indexterm" name="idm46045302752832">
  </a>
  <a class="indexterm" name="idm46045302751344">
  </a>
  <a class="indexterm" name="idm46045302750256">
  </a>
  <a class="indexterm" name="idm46045302748768">
  </a>
  <a class="indexterm" name="idm46045302747680">
  </a>
  <a class="indexterm" name="idm46045302746192">
  </a>
  <a class="indexterm" name="idm46045302745104">
  </a>
  <a class="indexterm" name="idm46045302743616">
  </a>
  <a class="indexterm" name="idm46045302742528">
  </a>
  <a class="indexterm" name="idm46045302741040">
  </a>
  <a class="indexterm" name="idm46045302739952">
  </a>
  <a class="indexterm" name="idm46045302738464">
  </a>
  <a class="indexterm" name="idm46045302737376">
  </a>
  <a class="indexterm" name="idm46045302735888">
  </a>
  <a class="indexterm" name="idm46045302734800">
  </a>
  <a class="indexterm" name="idm46045302733312">
  </a>
  <a class="indexterm" name="idm46045302732240">
  </a>
  <a class="indexterm" name="idm46045302730784">
  </a>
  <a class="indexterm" name="idm46045302729696">
  </a>
  <a class="indexterm" name="idm46045302728208">
  </a>
  <a class="indexterm" name="idm46045302727120">
  </a>
  <a class="indexterm" name="idm46045302725632">
  </a>
  <a class="indexterm" name="idm46045302724544">
  </a>
  <div class="informaltable">
   <table summary="Environment variables that are used directly or indirectly by MySQL.">
    <colgroup>
     <col style="width: 40%"/>
     <col style="width: 60%"/>
    </colgroup>
    <thead>
     <tr>
      <th>
       Variable
      </th>
      <th>
       Description
      </th>
     </tr>
    </thead>
    <tbody>
     <tr>
      <td>
       <code class="literal">
        AUTHENTICATION_KERBEROS_CLIENT_LOG
       </code>
      </td>
      <td>
       Kerberos authentication logging level.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        AUTHENTICATION_LDAP_CLIENT_LOG
       </code>
      </td>
      <td>
       Client-side LDAP authentication logging level.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        AUTHENTICATION_PAM_LOG
       </code>
      </td>
      <td>
       <a class="link" href="pam-pluggable-authentication.html#pam-pluggable-authentication-debugging" title="PAM Authentication Debugging">
        PAM
       </a>
       authentication plugin debug logging settings.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        CC
       </code>
      </td>
      <td>
       The name of your C compiler (for running
       <span class="command">
        <strong>
         CMake
        </strong>
       </span>
       ).
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        CXX
       </code>
      </td>
      <td>
       The name of your C++ compiler (for running
       <span class="command">
        <strong>
         CMake
        </strong>
       </span>
       ).
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        CC
       </code>
      </td>
      <td>
       The name of your C compiler (for running
       <span class="command">
        <strong>
         CMake
        </strong>
       </span>
       ).
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        DBI_USER
       </code>
      </td>
      <td>
       The default user name for Perl DBI.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        DBI_TRACE
       </code>
      </td>
      <td>
       Trace options for Perl DBI.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        HOME
       </code>
      </td>
      <td>
       The default path for 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>
       history file is
       <code class="filename">
        $HOME/.mysql_history
       </code>
       .
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        LD_RUN_PATH
       </code>
      </td>
      <td>
       Used to specify the location of
       <code class="filename">
        libmysqlclient.so
       </code>
       .
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN
       </code>
      </td>
      <td>
       Enable
       <code class="literal">
        mysql_clear_password
       </code>
       authentication plugin;
          see
       <a class="xref" href="cleartext-pluggable-authentication.html" title="8.4.1.4 Client-Side Cleartext Pluggable Authentication">
        Section 8.4.1.4, “Client-Side Cleartext Pluggable Authentication”
       </a>
       .
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        LIBMYSQL_PLUGIN_DIR
       </code>
      </td>
      <td>
       Directory in which to look for client plugins.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        LIBMYSQL_PLUGINS
       </code>
      </td>
      <td>
       Client plugins to preload.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        MYSQL_DEBUG
       </code>
      </td>
      <td>
       Debug trace options when debugging.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        MYSQL_GROUP_SUFFIX
       </code>
      </td>
      <td>
       Option group suffix value (like specifying
       <a class="link" href="option-file-options.html#option_general_defaults-group-suffix">
        <code class="option">
         --defaults-group-suffix
        </code>
       </a>
       ).
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        MYSQL_HISTFILE
       </code>
      </td>
      <td>
       The path to 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>
       history file. If this variable
          is set, its value overrides the default for
       <code class="filename">
        $HOME/.mysql_history
       </code>
       .
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        MYSQL_HISTIGNORE
       </code>
      </td>
      <td>
       Patterns specifying statements that
       <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
        <span class="command">
         <strong>
          mysql
         </strong>
        </span>
       </a>
       should not
          log to
       <code class="filename">
        $HOME/.mysql_history
       </code>
       , or
       <code class="literal">
        syslog
       </code>
       if
       <a class="link" href="mysql-command-options.html#option_mysql_syslog">
        <code class="option">
         --syslog
        </code>
       </a>
       is given.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        MYSQL_HOME
       </code>
      </td>
      <td>
       The path to the directory in which the server-specific
       <code class="filename">
        my.cnf
       </code>
       file resides.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        MYSQL_HOST
       </code>
      </td>
      <td>
       The default host name used by 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>
       command-line
          client.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        MYSQL_PS1
       </code>
      </td>
      <td>
       The command prompt to use in 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>
       command-line
          client.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        MYSQL_PWD
       </code>
      </td>
      <td>
       The default password when connecting to
       <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
        <span class="command">
         <strong>
          mysqld
         </strong>
        </span>
       </a>
       . Using
          this is insecure. See note following table.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        MYSQL_TCP_PORT
       </code>
      </td>
      <td>
       The default TCP/IP port number.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        MYSQL_TEST_LOGIN_FILE
       </code>
      </td>
      <td>
       The name of the
       <code class="filename">
        .mylogin.cnf
       </code>
       login path file.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        MYSQL_TEST_TRACE_CRASH
       </code>
      </td>
      <td>
       Whether the test protocol trace plugin crashes clients. See note
          following table.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        MYSQL_TEST_TRACE_DEBUG
       </code>
      </td>
      <td>
       Whether the test protocol trace plugin produces output. See note
          following table.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        MYSQL_UNIX_PORT
       </code>
      </td>
      <td>
       The default Unix socket file name; used for connections to
       <code class="literal">
        localhost
       </code>
       .
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        MYSQLX_TCP_PORT
       </code>
      </td>
      <td>
       The X Plugin default TCP/IP port number.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        MYSQLX_UNIX_PORT
       </code>
      </td>
      <td>
       The X Plugin default Unix socket file name; used for connections to
       <code class="literal">
        localhost
       </code>
       .
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        NOTIFY_SOCKET
       </code>
      </td>
      <td>
       Socket used by
       <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
        <span class="command">
         <strong>
          mysqld
         </strong>
        </span>
       </a>
       to communicate with systemd.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        PATH
       </code>
      </td>
      <td>
       Used by the shell to find MySQL programs.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        PKG_CONFIG_PATH
       </code>
      </td>
      <td>
       Location of
       <code class="filename">
        mysqlclient.pc
       </code>
       <span class="command">
        <strong>
         pkg-config
        </strong>
       </span>
       file. See note following table.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        TMPDIR
       </code>
      </td>
      <td>
       The directory in which temporary files are created.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        TZ
       </code>
      </td>
      <td>
       This should be set to your local time zone. See
       <a class="xref" href="timezone-problems.html" title="B.3.3.7 Time Zone Problems">
        Section B.3.3.7, “Time Zone Problems”
       </a>
       .
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        UMASK
       </code>
      </td>
      <td>
       The user-file creation mode when creating files. See note following
          table.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        UMASK_DIR
       </code>
      </td>
      <td>
       The user-directory creation mode when creating directories. See note
          following table.
      </td>
     </tr>
     <tr>
      <td>
       <code class="literal">
        USER
       </code>
      </td>
      <td>
       The default user name on Windows when connecting to
       <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
        <span class="command">
         <strong>
          mysqld
         </strong>
        </span>
       </a>
       .
      </td>
     </tr>
    </tbody>
   </table>
  </div>
  <div class="informaltable">
   <table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 401px; width: 739px;">
    <thead>
     <tr>
      <th style="width: 295.188px;">
       Variable
      </th>
      <th style="width: 442.812px;">
       Description
      </th>
     </tr>
    </thead>
   </table>
  </div>
  <p>
   For information about 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>
   history file, see
   <a class="xref" href="mysql-logging.html" title="6.5.1.3 mysql Client Logging">
    Section 6.5.1.3, “mysql Client Logging”
   </a>
   .
  </p>
  <p>
   Use of
   <code class="literal">
    MYSQL_PWD
   </code>
   to specify a MySQL password must
    be considered
   <span class="emphasis">
    <em>
     extremely insecure
    </em>
   </span>
   and should not
    be used. Some versions of
   <span class="command">
    <strong>
     ps
    </strong>
   </span>
   include an option to
    display the environment of running processes. On some systems, if
    you set
   <code class="literal">
    MYSQL_PWD
   </code>
   , your password is exposed to
    any other user who runs
   <span class="command">
    <strong>
     ps
    </strong>
   </span>
   . Even on systems
    without such a version of
   <span class="command">
    <strong>
     ps
    </strong>
   </span>
   , it is unwise to
    assume that there are no other methods by which users can examine
    process environments.
  </p>
  <p>
   <code class="literal">
    MYSQL_PWD
   </code>
   is deprecated as of MySQL
    8.4; expect it to be removed in a future version of
    MySQL.
  </p>
  <p>
   <code class="literal">
    MYSQL_TEST_LOGIN_FILE
   </code>
   is the path name of the
    login path file (the file created 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>
   ). If not set, the default
    value is
   <code class="filename">
    %APPDATA%\MySQL\.mylogin.cnf
   </code>
   directory
    on Windows and
   <code class="filename">
    $HOME/.mylogin.cnf
   </code>
   on
    non-Windows systems. 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>
   .
  </p>
  <p>
   The
   <code class="literal">
    MYSQL_TEST_TRACE_DEBUG
   </code>
   and
   <code class="literal">
    MYSQL_TEST_TRACE_CRASH
   </code>
   variables control the test
    protocol trace client plugin, if MySQL is built with that plugin
    enabled. For more information, see
   <a class="ulink" href="/doc/extending-mysql/8.4/en/test-protocol-trace-plugin.html" target="_top">
    Using the Test Protocol Trace Plugin
   </a>
   .
  </p>
  <p>
   The default
   <code class="literal">
    UMASK
   </code>
   and
   <code class="literal">
    UMASK_DIR
   </code>
   values are
   <code class="literal">
    0640
   </code>
   and
   <code class="literal">
    0750
   </code>
   , respectively. MySQL assumes that the value
    for
   <code class="literal">
    UMASK
   </code>
   or
   <code class="literal">
    UMASK_DIR
   </code>
   is in
    octal if it starts with a zero. For example, setting
   <code class="literal">
    UMASK=0600
   </code>
   is equivalent to
   <code class="literal">
    UMASK=384
   </code>
   because 0600 octal is 384 decimal.
  </p>
  <p>
   The
   <code class="literal">
    UMASK
   </code>
   and
   <code class="literal">
    UMASK_DIR
   </code>
   variables, despite their names, are used as modes, not masks:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      If
      <code class="literal">
       UMASK
      </code>
      is set,
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      uses
      <code class="literal">
       ($UMASK | 0600)
      </code>
      as the mode for file
        creation, so that newly created files have a mode in the range
        from 0600 to 0666 (all values octal).
     </p>
    </li>
    <li class="listitem">
     <p>
      If
      <code class="literal">
       UMASK_DIR
      </code>
      is set,
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      uses
      <code class="literal">
       ($UMASK_DIR |
        0700)
      </code>
      as the base mode for directory creation, which
        then is AND-ed with
      <code class="literal">
       ~(~$UMASK &amp; 0666)
      </code>
      , so
        that newly created directories have a mode in the range from
        0700 to 0777 (all values octal). The AND operation may remove
        read and write permissions from the directory mode, but not
        execute permissions.
     </p>
    </li>
   </ul>
  </div>
  <p>
   See also
   <a class="xref" href="file-permissions.html" title="B.3.3.1 Problems with File Permissions">
    Section B.3.3.1, “Problems with File Permissions”
   </a>
   .
  </p>
  <p>
   It may be necessary to set
   <code class="literal">
    PKG_CONFIG_PATH
   </code>
   if you
    use
   <span class="command">
    <strong>
     pkg-config
    </strong>
   </span>
   for building MySQL programs. See
   <a class="ulink" href="/doc/c-api/8.4/en/c-api-building-clients-pkg-config.html" target="_top">
    Building C API Client Programs Using pkg-config
   </a>
   .
  </p>
 </div>
 <br/>
</div>
