4.3.3. Using Environment Variables to Specify Options
To specify an option using an environment variable, set the
variable using the syntax appropriate for your command
processor. For example, on Windows or NetWare, you can set the
USER
variable to specify your MySQL account
name. To do so, use this syntax:
SET USER=your_name
The syntax on Unix depends on your shell. Suppose that you want
to specify the TCP/IP port number using the
MYSQL_TCP_PORT
variable. Typical syntax (such
as for sh, bash
,
zsh, and so on) is as follows:
MYSQL_TCP_PORT=3306
export MYSQL_TCP_PORT
The first command sets the variable, and the
export
command exports the variable to the
shell environment so that its value becomes accessible to MySQL
and other processes.
For csh and tcsh, use
setenv to make the shell variable available
to the environment:
setenv MYSQL_TCP_PORT 3306
The commands to set environment variables can be executed at
your command prompt to take effect immediately, but the settings
persist only until you log out. To have the settings take effect
each time you log in, place the appropriate command or commands
in a startup file that your command interpreter reads each time
it starts. Typical startup files are
AUTOEXEC.BAT
for Windows,
.bash_profile
for bash,
or .tcshrc
for tcsh.
Consult the documentation for your command interpreter for
specific details.
Appendix F, Environment Variables, lists all environment
variables that affect MySQL program operation.