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.
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 Using Option Files.
To set an environment variable within sh,
ksh, bash, or
zsh shells you can use the following commands:
shell>ENVVAR=valueshell> exportENVVAR
The export is required if you want other
sub-commands to inherit that value during execution. On more recent
shells you can combine the export and setting processes, like this:
shell> export setENVVAR=value
For the csh, or tcsh shells, use the setenv command:
shell> setenvENVVARvalue
Within the Windows Command Prompt use the set command to specify the value of a variable:
shell> setENVVAR=value
On Unix, Linux, OS X, and Windows, the set command without parameters will display the list of currently set variables.
Table 12.1 MySQL Related Environment Variables
| Variable | Description |
|---|---|
CXX | The name of your C++ compiler (for running configure). |
CC | The name of your C compiler (for running configure). |
CFLAGS | Flags for your C compiler (for running configure). |
CXXFLAGS | Flags for your C++ compiler (for running configure). |
DBI_USER | The default user name for Perl DBI. |
DBI_TRACE | Trace options for Perl DBI. |
HOME | The default path for the mysql history file is
$HOME/.mysql_history. |
LD_RUN_PATH | Used to specify the location of libmysqlclient.so. |
MYSQL_DEBUG | Debug trace options when debugging. |
MYSQL_GROUP_SUFFIX | Option group suffix value (like specifying
--defaults-group-suffix). |
MYSQL_HISTFILE | The path to the mysql history file. If this variable
is set, its value overrides the default for
$HOME/.mysql_history. |
MYSQL_HOME | The path to the directory in which the server-specific
my.cnf file resides. |
MYSQL_HOST | The default host name used by the mysql command-line client. |
MYSQL_PS1 | The command prompt to use in the mysql command-line client. |
MYSQL_PWD | The default password when connecting to mysqld. Using this is insecure. See End-User Guidelines for Password Security. |
MYSQL_TCP_PORT | The default TCP/IP port number. |
MYSQL_UNIX_PORT | The default Unix socket file name; used for connections to
localhost. |
PATH | Used by the shell to find MySQL programs. |
TMPDIR | The directory in which temporary files are created. |
TZ | This should be set to your local time zone. See Time Zone Problems. |
UMASK | The user-file creation mode when creating files. See note following table. |
UMASK_DIR | The user-directory creation mode when creating directories. See note following table. |
USER | The default user name on Windows and NetWare when connecting to mysqld. |
For information about the mysql history file, see mysql Logging.
The default UMASK and
UMASK_DIR values are 0660 and
0700, respectively. MySQL assumes that the value
for UMASK or UMASK_DIR is in
octal if it starts with a zero. For example, setting
UMASK=0600 is equivalent to
UMASK=384 because 0600 octal is 384 decimal.
The UMASK and UMASK_DIR
variables, despite their names, are used as modes, not masks:
If UMASK is set, mysqld
uses ($UMASK | 0600) as the mode for file
creation, so that newly created files have a mode in the range
from 0600 to 0666 (all values octal).
If UMASK_DIR is set,
mysqld uses ($UMASK_DIR |
0700) as the base mode for directory creation, which
then is AND-ed with ~(~$UMASK & 0666), 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.