1.9.1 Problem
You need to modify your operating environment, for example, to change your shell's PATH setting.
1.9.2 Solution
Edit the appropriate shell startup file. Under Windows NT-based systems, another alternative is to use the System control panel.
1.9.3 Discussion
The shell or command interpreter you use to run programs from the command-line prompt includes an environment in which you can store variable values. Some of these variables are used by the shell itself. For example, it uses PATH to determine which directories to look in for programs such as mysql. Other variables are used by other programs (such as PERL5LIB, which tells Perl where to look for library files used by Perl scripts).
Your shell determines the syntax used to set environment variables, as well as the startup file in which to place the settings. Typical startup files for various shells are shown in the following table. If you've never looked through your shell's startup files, it's a good idea to do so to familiarize yourself with their contents.
Shell |
Possible startup files |
---|---|
csh, tcsh |
.login, .cshrc, .tcshrc |
sh, bash, ksh |
.profile .bash_profile, .bash_login, .bashrc |
DOS prompt |
C:AUTOEXEC.BAT |
The following examples show how to set the PATH variable so that it includes the directory where the mysql program is installed. The examples assume there is an existing PATH setting in one of your startup files. If you have no PATH setting currently, simply add the appropriate line or lines to one of the files.
|
The PATH variable lists the pathnames for one or more directories. If an environment variable's value consists of multiple pathnames, it's conventional under Unix to separate them using the colon character (:). Under Windows, pathnames may contain colons, so the separator is the semicolon character ( ;).
To set the value of PATH, use the instructions that pertain to your shell:
setenv PATH /bin:/usr/bin:/usr/local/bin
If mysql is installed in /usr/local/mysql/bin, add that directory to the search path by changing the setenv line to look like this:
setenv PATH /usr/local/mysql/bin:/bin:/usr/bin:/usr/local/bin
It's also possible that your path will be set with set path, which uses different syntax:
set path = (/usr/local/mysql/bin /bin /usr/bin /usr/local/bin)
export PATH=/bin:/usr/bin:/usr/local/bin
The assignment and the export might be on separate lines:
PATH=/bin:/usr/bin:/usr/local/bin export PATH
Change the setting to this:
export PATH=/usr/local/mysql/bin:/bin:/usr/bin:/usr/local/bin
Or:
PATH=/usr/local/mysql/bin:/bin:/usr/bin:/usr/local/bin export PATH
PATH=C:WINDOWS;C:WINDOWSCOMMAND
Or like this:
SET PATH=C:WINDOWS;C:WINDOWSCOMMAND
Change the PATH value to include the directory where mysql is installed. If this is C:mysqlin, the resulting PATH setting looks like this:
PATH=C:mysqlin;C:WINDOWS;C:WINDOWSCOMMAND
Or:
SET PATH=C:mysqlin;C:WINDOWS;C:WINDOWSCOMMAND
After setting an environment variable, you'll need to cause the modification to take effect. Under Unix, you can log out and log in again. Under Windows, if you set PATH using the System control panel, you can simply open a new DOS window. If you edited AUTOEXEC.BAT instead, restart the machine.
Using the mysql Client Program
Writing MySQL-Based Programs
Record Selection Techniques
Working with Strings
Working with Dates and Times
Sorting Query Results
Generating Summaries
Modifying Tables with ALTER TABLE
Obtaining and Using Metadata
Importing and Exporting Data
Generating and Using Sequences
Using Multiple Tables
Statistical Techniques
Handling Duplicates
Performing Transactions
Introduction to MySQL on the Web
Incorporating Query Resultsinto Web Pages
Processing Web Input with MySQL
Using MySQL-Based Web Session Management
Appendix A. Obtaining MySQL Software
Appendix B. JSP and Tomcat Primer
Appendix C. References