Tải bản đầy đủ (.pdf) (20 trang)

Mysql your visual blueprint for creating open source databases- P15 pdf

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (519.28 KB, 20 trang )

ADMINISTRATIVE COMMANDS
M
ySQL includes a variety of administrative
commands for managing tables, processes, users,
and various server components.
MYSQL COMMAND REFERENCE
B
OPTIMIZE TABLE
The OPTIMIZE TABLE command sorts a table's index
files and reclaims any space used by deleted rows. To
use this command, specify the table name.
Example:
OPTIMIZE TABLE address;
CHECK TABLE
The CHECK TABLE command checks a table for errors.
Specify a table name and optionally one or more of the
keywords QUICK, FAST, CHANGED, MEDIUM, or EXTENDED.
Example:
CHECK TABLE address;
REPAIR TABLE
The REPAIR TABLE command attempts to repair a
damaged table. You can optionally specify the keywords
QUICK for a fast scan or EXTENDED for a more thorough
scan.
ANALYZE TABLE
The ANALYZE TABLE command analyzes a table's
content and configures its keys for use in future queries.
To use this command, specify the table name.
FLUSH HOSTS
The FLUSH HOSTS command clears the host cache
tables MySQL uses to manage access by users from


remote hosts. This allows access by users who were
previously blocked due to connection errors.
FLUSH LOGS
This command closes and reopens the MySQL log files.
It is useful if you have changed logging settings or if you
are backing up or deleting old data in the log files.
FLUSH PRIVILEGES
This command reloads the MySQL grant tables, used to
control access by users. This is useful if you have made
changes to the tables manually.
FLUSH QUERY CACHE
This command arranges MySQL's cache of queries in
memory to conserve memory. Use the command RESET
QUERY CACHE to clear this cache completely.
FLUSH TABLES
This command closes and reopens all MySQL tables,
and clears the query cache.
FLUSH STATUS
This command resets most of the status variables that
are shown with the SHOW STATUS command. These
variables are also cleared each time you start the
MySQL server.
KILL
This command stops a thread on the MySQL server.
Specify the process ID number, available from the
output of SHOW PROCESSLIST.
Example:
KILL 3931;
GRANT
The GRANT command grants one or more privileges to a

user of the MySQL server. If the user does not already
exist, it is created. Specify the privileges to grant, the
database and table names, the TO keyword followed by
the username, and the IDENTIFIED BY keywords
followed by a password.
Example:
GRANT ALL ON testdb.quotes
TO fred IDENTIFIED BY 'password';
REVOKE
The REVOKE command takes away one or more privileges
from a user of the MySQL server. Specify the privileges to
revoke, the FROM keyword, and the username.
Example:
REVOKE ALL ON testdb.quotes FROM fred;
267
6516922 AppB.F 9/26/02 11:41 AM Page 267
M
ySQL includes a number of utilities that can be
used from the command prompt on a UNIX or
Windows system. These are described in the
following sections.
COMMAND-LINE UTILITIES
This command starts the MySQL monitor, a
command-line interface that enables you to
enter MySQL commands and view their
results.
COMMAND DESCRIPTION
-?
Display a complete list of
options

-D Select a database to use
-h Specify the host (server name
or IP address)
-p Specify the password to
access the server
-P Specify the TCP/IP port
number for the server
-u Specify a username for the
server
-V Display server version number
After you are in the MySQL monitor, you can type any MySQL
command. The monitor also supports a number of special
commands:
COMMAND DESCRIPTION
\c Clears the current command
\e Edits the command in a text editor
\g Executes the current command
\G Executes the current command and displays a
vertical result
\h Displays a list of commands and their
descriptions
\p Displays the current command
\q Exits the MySQL monitor
\r Attempts to reconnect to the server
\s Displays MySQL status information
\ Executes MySQL commands from a specified file
MYSQL
APPENDIX
The mysqladmin utility runs from a client machine and supports
a number of different commands for managing the MySQL server.

Type mysqladmin followed by the command name.
Example:
mysqladmin extended-status
MYSQLADMIN
COMMAND DESCRIPTION
create Create a database
drop Drop a database
ping Check whether the server is
running
status Display basic status information
extended-status Display a detailed status report
processlist Show a list of the current MySQL
server processes
COMMAND DESCRIPTION
kill Stop one or more server processes
variables List MySQL variables and their
values
version Display the MySQL server version
number
shutdown Shut down the MySQL server
password Change the password for the
current MySQL user
268
6516922 AppB.F 9/26/02 11:41 AM Page 268
MYSQL COMMAND REFERENCE
B
269
OPTION DESCRIPTION
-A
or all-databases Includes all databases on

the server
-C or compress Attempts to compress data
-B or databases Backs up multiple databases
—help Displays a complete list of
options
-f or force Ignores MySQL errors
To use mysqldump, specify a database and a list of
tables on the command line. If you do not specify
tables, the entire database is included in the dump.
OPTION DESCRIPTION
-h
or host Specifies the server hostname
for the MySQL server
-u or user Specifies the MySQL
username
-p or password Specifies the password
-t or no-create-info Writes data only, no table
structure
Example:
mysqldump -uuser -ppassword testdb address
>backup.sql
MYSQLDUMP
The mysqldump utility dumps the contents of a table or an entire
database to the screen, and you can redirect its output to a file. This
command creates a file of SQL commands to re-create the table.
The myisamchk utility checks MyISAM tables
for errors and optionally attempts to repair any
problems found. This utility works directly on
the MySQL data files, and should be used while
the server is not running or no users are

accessing the tables being checked.
Example:
myisamchk –r /var/mysql/data/testdb/address
The following table describes some of the most
useful command-line options for the
myisamchk utility.
OPTION DESCRIPTION
-e Extended check: slow but more thorough
-m Medium check: faster than extended
-F Fast check: only checks improperly closed tables
-C Checks only tables changed since the last check
-i Displays information about the table while checking
-f Automatically repairs the table if any errors are detected
-r Recover: attempts to repair table and recover data
-o Safe recover: uses a slower and safer recovery method
-q Quick recover: checks index files only
-w Waits until no clients are locking the table before checking
MYISAMCHK
6516922 AppB.F 9/26/02 11:41 AM Page 269
WHAT'S ON THE CD-ROM
270
APPENDIX
T
he CD-ROM included in this book contains many
useful files and programs. Before installing any of the
programs on the disc, make sure that you do not
already have a newer version of the program already
installed on your computer. For information on installing
different versions of the same program, contact the
program's manufacturer. For the latest and greatest

information, please refer to the ReadMe file located at the
root level of the CD-ROM.
SYSTEM REQUIREMENTS
To use the contents of the CD-ROM, your computer must
have the following hardware and software:
• A PC with a Pentium or faster processor
• Microsoft Windows 95, 98, ME, NT, 2000, or XP; or Linux
or UNIX. MySQL can also be compiled on other systems,
such as Mac OSX.
• At least 128MB of physical RAM installed on your
computer
• A double-speed (8x) or faster CD-ROM drive
• A monitor capable of displaying at least 256 colors or
grayscale
• A network card
AUTHOR'S SOURCE CODE
These files include SQL files you can use to create the
example tables used throughout the book as well as the
sample PHP and Perl code from Chapters 12 and 13. You
can browse the files directly from the CD-ROM, or you can
copy them to your hard drive and use them as the basis for
your own projects. To find the files on the CD-ROM, open
the \Samples folder on the CD-ROM drive.
To import an SQL file, use the MySQL monitor from the
command line and specify the database:
mysql testdb <file.sql
You must create the testdb database, as described in
Chapter 1, before importing any files. Chapter 1 also
includes more information about the MySQL monitor.
See Chapter 8 for more information about importing and

exporting files.
ACROBAT VERSION
The CD-ROM contains an e-version of this book that you
can view and search using Adobe Acrobat Reader. You can
also use the hyperlinks provided in the text to access all the
Web pages and Internet references in the book. You cannot
print the pages or copy text from the Acrobat files. The
CD-ROM includes a freeware version of Adobe Acrobat
Reader.
INSTALLING AND USING THE SOFTWARE
For your convenience, the software titles appearing on the
CD-ROM are listed alphabetically.
Acrobat Reader
For Windows 95/98/NT/2000 and Linux. Freeware.
Adobe Acrobat Reader allows you to view the online
version of this book. For more information on using Acrobat
Reader, see the section "Using the E-Version of this Book" in
this appendix. For more information about Acrobat Reader
and Adobe Systems, see www.adobe.com.
Apache
For Windows and UNIX. Open source.
Apache is a Web server from the Apache Software
Foundation. It is used throughout the world on a large
number of Web sites. It supports PHP and Perl as modules
and integrates well with MySQL.
You can download the latest version of Apache as well as
view information, such as troubleshooting tips and FAQs, at
the www.apache.org Web site.
6516922 AppC.F 9/26/02 11:41 AM Page 270
WHAT

'
S ON THE CD-ROM
C
271
MySQL
For Windows and UNIX. GNU version.
MySQL is a fast and reliable database management system.
It includes powerful features that allow you to add, access,
and process information stored in databases. The latest
version of MySQL also features full-text searching and
indexing capabilities.
MySQL is free for non-commercial use. For more
information about MySQL or to download server or
client software, visit the www.mysql.com Web site.
Perl
For Windows and UNIX. Open source.
Perl is a powerful scripting language with features that
make it ideal for text processing and as a language for
dynamic Web pages. Perl is a popular language for creating
database applications and database-driven Web sites with
MySQL.
Perl is open source software. For more information about
Perl or to download source code or binary distributions,
visit the www.perl.org Web site.
Perl DBI and DBD: MySQL
For Windows and UNIX. GNU version.
The DBI is a programmatic interface that allows the Perl
language to connect to a variety of database management
systems, including MySQL. It supports DBDs, or database
drivers, for each database system. The MySQL DBD is also

included on the CD-ROM.
The DBI and the MySQL DBD are open source software.
For more information on the DBI or to download the latest
version, visit the Web site at .
PHP
For Windows and UNIX. Open source.
PHP is a powerful server-side scripting language that
integrates with HTML. You must have PHP installed on your
Web server in order to create and view PHP Web pages.
PHP is free, open source software. For more information
about PHP or to download the latest version, visit the
www.php.net Web site.
phpMyAdmin
For Windows and UNIX. GNU version.
phpMyAdmin administers the MySQL database management
system on the Web. It allows you to create and edit
databases and tables, execute SQL statements, and
administer multiple databases and servers.
TROUBLESHOOTING
The programs on the CD-ROM should work on computers
with the minimum of system requirements. However, some
programs may not work properly.
The two most likely problems for the programs not working
properly include not having enough memory (RAM) for the
programs you want to use, or having other programs running
that affect the installation or running of a program. If you
receive error messages such as Not enough memory or
Setup cannot continue, try one or more of the methods
below and then try using the software again:
• Turn off any anti-virus software

• Close all running programs
• In Windows, close the CD-ROM interface and run
demos or installations directly from Windows Explorer
• Have your local computer store add more RAM to your
computer
If you still have trouble installing the items from the
CD-ROM, call the Wiley Customer Service phone number:
800-762-2974 (outside the U.S.: 317-572-3994). You can also
contact Wiley Customer Service by e-mail at

6516922 AppC.F 9/26/02 11:41 AM Page 271
FLIP THROUGH PAGES
⁄ Click one of these options
to flip through the pages of a
section.
First page
Previous page
Next page
Last page
ZOOM IN
⁄ Click to magnify an
area of the page.
¤ Click the area of the page
you want to magnify.
■ Click one of these options
to display the page at 100%
magnification ( ) or to fit
the entire page inside the
window ( ).
Y

ou can view MySQL: Your visual blueprint to open
source database management on your screen using
the CD-ROM included at the back of this book. The
CD-ROM allows you to search the contents of each chapter
of the book for a specific word or phrase. The CD-ROM
also provides a convenient way of keeping the book handy
while traveling.
You must install Adobe Acrobat Reader on your computer
before you can view the book on the CD-ROM. The
CD-ROM includes this program for your convenience.
Acrobat Reader allows you to view Portable Document
Format (PDF) files, which can display books and magazines
on your screen exactly as they appear in printed form.
Acrobat Reader is a popular and useful program. There are
many files available on the Web that are designed to be
viewed using Acrobat Reader. Look for files with the .pdf
extension. For more information about Acrobat Reader,
visit the Web site at www.adobe.com/products/acrobat/
reader.html.
To view the contents of the book using Acrobat Reader,
display the main menu on the CD-ROM. Click the eBook
link, select the section of the book you want to view, and
then click Install.
USING THE E-VERSION OF THIS BOOK
272
FIG HEAD
APPENDIX
USING THE E-VERSION OF THIS BOOK
6516922 AppC.F 9/26/02 11:41 AM Page 272
To install Acrobat Reader, insert the CD-ROM

into a drive. In the screen that appears, click
Software. Click Acrobat Reader and then follow
the instructions on your screen to install the
program.
You can make searching the book more
convenient by copying the PDF files to your
computer. To do this, display the contents of the
CD-ROM and then copy the Book folder from the
CD-ROM to your hard drive. This allows you to
easily access the contents of the book at any time.
When you search for text, the text that Acrobat
Reader highlights may be difficult to read. To make
highlighted text easier to read, turn off the font
smoothing capabilities of Acrobat Reader. In the
Acrobat Reader window, click Edit ➪ Preferences.
Click Display at the left side of the Preferences
dialog box. In the Smoothing area, click Smooth
Text ( changes to ), and then click OK.
273
WHAT'S ON THE CD-ROM
C
FIND TEXT
⁄ Click to search for text
in the section.
■ The Find dialog box
appears.
¤ Type the text you want to
find.
‹ Click Find to start the
search.

■ The first instance of the
text is highlighted.
› Click Find Again to find
the next instance of the text.
database
6516922 AppC.F 9/26/02 11:41 AM Page 273
274
WILEY PUBLISHING, INC.
END-USER LICENSE AGREEMENT
READ THIS. You should carefully read these terms and
conditions before opening the software packet(s) included
with MySQL: Your visual blueprint to open source database
management ("Book"). This is a license agreement
("Agreement") between you and Wiley Publishing, Inc.
("WPI"). By opening the accompanying software packet(s),
you acknowledge that you have read and accept the
following terms and conditions. If you do not agree and do
not want to be bound by such terms and conditions,
promptly return the Book and the unopened software
packet(s) to the place you obtained them for a full refund.
1. License Grant.
WPI grants to you (either an individual or entity) a
nonexclusive license to use one copy of the enclosed
software program(s) (collectively, the "Software") solely for
your own personal or business purposes on a single
computer (whether a standard computer or a workstation
component of a multi-user network). The Software is in use
on a computer when it is loaded into temporary memory
(RAM) or installed into permanent memory (hard disk,
CD-ROM, or other storage device). WPI reserves all rights

not expressly granted herein.
2. Ownership.
WPI is the owner of all right, title, and interest, including
copyright, in and to the compilation of the Software
recorded on the disk(s) or CD-ROM "Software Media."
Copyright to the individual programs recorded on the
Software Media is owned by the author or other authorized
copyright owner of each program. Ownership of the
Software and all proprietary rights relating thereto remain
with WPI and its licensers.
3. Restrictions On Use and Transfer.
(a) You may only (i) make one copy of the Software for
backup or archival purposes, or (ii) transfer the Software to
a single hard disk, provided that you keep the original for
backup or archival purposes. You may not (i) rent or lease
the Software, (ii) copy or reproduce the Software through a
LAN or other network system or through any computer
subscriber system or bulletin-board system, or (iii) modify,
adapt, or create derivative works based on the Software.
(b) You may not reverse engineer, decompile, or
disassemble the Software. You may transfer the Software
and user documentation on a permanent basis, provided
that the transferee agrees to accept the terms and
conditions of this Agreement and you retain no copies. If
the Software is an update or has been updated, any transfer
must include the most recent update and all prior versions.
4. Restrictions on Use of Individual Programs.
You must follow the individual requirements and
restrictions detailed for each individual program in
Appendix C of this Book. These limitations are also

contained in the individual license agreements recorded on
the Software Media. These limitations may include a
requirement that after using the program for a specified
period of time, the user must pay a registration fee or
discontinue use. By opening the Software packet(s), you will
be agreeing to abide by the licenses and restrictions for
these individual programs that are detailed in Appendix C
and on the Software Media. None of the material on this
Software Media or listed in this Book may ever be
redistributed, in original or modified form, for commercial
purposes.
5. Limited Warranty.
(a) WPI warrants that the Software and Software Media
are free from defects in materials and workmanship under
normal use for a period of sixty (60) days from the date of
purchase of this Book. If WPI receives notification within
the warranty period of defects in materials or workmanship,
WPI will replace the defective Software Media.
APPENDIX
6516922 AppC.F 9/26/02 11:41 AM Page 274
WHAT'S ON THE CD-ROM
C
275
(b) WPI AND THE AUTHOR OF THE BOOK DISCLAIM
ALL OTHER WARRANTIES, EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE, WITH RESPECT TO THE
SOFTWARE, THE PROGRAMS, THE SOURCE CODE
CONTAINED THEREIN, AND/OR THE TECHNIQUES

DESCRIBED IN THIS BOOK. WPI DOES NOT WARRANT
THAT THE FUNCTIONS CONTAINED IN THE SOFTWARE
WILL MEET YOUR REQUIREMENTS OR THAT THE
OPERATION OF THE SOFTWARE WILL BE ERROR FREE.
(c) This limited warranty gives you specific legal rights, and
you may have other rights that vary from jurisdiction to
jurisdiction.
6. Remedies.
(a) WPI's entire liability and your exclusive remedy for
defects in materials and workmanship shall be limited to
replacement of the Software Media, which may be returned
to WPI with a copy of your receipt at the following address:
Software Media Fulfillment Department, Attn.: MySQL: Your
visual blueprint to open source database management,
Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis,
IN 46256, or call 1-800-762-2974. Please allow four to six
weeks for delivery. This Limited Warranty is void if failure of
the Software Media has resulted from accident, abuse, or
misapplication. Any replacement Software Media will be
warranted for the remainder of the original warranty period
or thirty (30) days, whichever is longer.
(b) In no event shall WPI or the author be liable for any
damages whatsoever (including without limitation damages
for loss of business profits, business interruption, loss of
business information, or any other pecuniary loss) arising
from the use of or inability to use the Book or the Software,
even if WPI has been advised of the possibility of such
damages.
(c) Because some jurisdictions do not allow the exclusion
or limitation of liability for consequential or incidental

damages, the above limitation or exclusion may not apply
to you.
7. U.S. Government Restricted Rights.
Use, duplication, or disclosure of the Software for or on
behalf of the United States of America, its agencies and/or
instrumentalities "U.S. Government" is subject to
restrictions as stated in paragraph (c)(1)(ii) of the Rights in
Technical Data and Computer Software clause of DFARS
252.227-7013, or subparagraphs (c) (1) and (2) of the
Commercial Computer Software - Restricted Rights clause
at FAR 52.227-19, and in similar clauses in the NASA FAR
supplement, as applicable.
8. General.
This Agreement constitutes the entire understanding of the
parties and revokes and supersedes all prior agreements,
oral or written, between them and may not be modified or
amended except in a writing signed by both parties hereto
that specifically refers to this Agreement. This Agreement
shall take precedence over any other documents that may
be in conflict herewith. If any one or more provisions
contained in this Agreement are held by any court or
tribunal to be invalid, illegal, or otherwise unenforceable,
each and every other provision shall remain in full force and
effect.
6516922 AppC.F 9/26/02 11:41 AM Page 275
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright © 1989, 1991 Free Software Foundation, Inc.
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Everyone is permitted to copy and distribute verbatim

copies of this license document, but changing it is not
allowed.
PREAMBLE
The licenses for most software are designed to take away
your freedom to share and change it. By contrast, the GNU
General Public License is intended to guarantee your
freedom to share and change free software—to make sure
the software is free for all its users. This General Public
License applies to most of the Free Software Foundation's
software and to any other program whose authors commit
to using it. (Some other Free Software Foundation software
is covered by the GNU Library General Public License
instead.) You can apply it to your programs, too.
When we speak of free software, we are referring to
freedom, not price. Our General Public Licenses are
designed to make sure that you have the freedom to
distribute copies of free software (and charge for this
service if you wish), that you receive source code or can get
it if you want it, that you can change the software or use
pieces of it in new free programs; and that you know you
can do these things.
To protect your rights, we need to make restrictions that
forbid anyone to deny you these rights or to ask you to
surrender the rights. These restrictions translate to certain
responsibilities for you if you distribute copies of the
software, or if you modify it.
For example, if you distribute copies of such a program,
whether gratis or for a fee, you must give the recipients all
the rights that you have. You must make sure that they, too,
receive or can get the source code. And you must show

them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the
software, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the software.
Also, for each author's protection and ours, we want to
make certain that everyone understands that there is no
warranty for this free software. If the software is modified
by someone else and passed on, we want its recipients to
know that what they have is not the original, so that any
problems introduced by others will not reflect on the
original authors' reputations.
Finally, any free program is threatened constantly by
software patents. We wish to avoid the danger that
redistributors of a free program will individually obtain
patent licenses, in effect making the program proprietary.
To prevent this, we have made it clear that any patent must
be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution,
and modification follow.
TERMS AND CONDITIONS FOR COPYING,
DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work
which contains a notice placed by the copyright holder
saying it may be distributed under the terms of this
General Public License. The "Program", below, refers to
any such program or work, and a "work based on the
Program" means either the Program or any derivative
work under copyright law: that is to say, a work
containing the Program or a portion of it, either
verbatim or with modifications and/or translated into

another language. (Hereinafter, translation is included
without limitation in the term "modification".) Each
licensee is addressed as "you".
Activities other than copying, distribution and
modification are not covered by this License; they are
outside its scope. The act of running the Program is not
restricted, and the output from the Program is covered
only if its contents constitute a work based on the
Program (independent of having been made by running
the Program). Whether that is true depends on what the
Program does.
1. You may copy and distribute verbatim copies of the
Program's source code as you receive it, in any
medium, provided that you conspicuously and
appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep
intact all the notices that refer to this License and to
the absence of any warranty; and give any other
recipients of the Program a copy of this License along
with the Program.
You may charge a fee for the physical act of transferring
a copy, and you may at your option offer warranty
protection in exchange for a fee.
276
APPENDIX
6516922 AppC.F 9/26/02 11:41 AM Page 276
277
2. You may modify your copy or copies of the Program or
any portion of it, thus forming a work based on the
Program, and copy and distribute such modifications or

work under the terms of Section 1 above, provided that
you also meet all of these conditions:
a) You must cause the modified files to carry
prominent notices stating that you changed the files
and the date of any change.
b) You must cause any work that you distribute or
publish, that in whole or in part contains or is
derived from the Program or any part thereof, to be
licensed as a whole at no charge to all third parties
under the terms of this License.
c) If the modified program normally reads commands
interactively when run, you must cause it, when
started running for such interactive use in the most
ordinary way, to print or display an announcement
including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that
you provide a warranty) and that users may
redistribute the program under these conditions,
and telling the user how to view a copy of this
License. (Exception: if the Program itself is
interactive but does not normally print such an
announcement, your work based on the Program is
not required to print an announcement.)
These requirements apply to the modified work as a
whole. If identifiable sections of that work are not
derived from the Program, and can be reasonably
considered independent and separate works in
themselves, then this License, and its terms, do not
apply to those sections when you distribute them as
separate works. But when you distribute the same

sections as part of a whole which is a work based on
the Program, the distribution of the whole must be
on the terms of this License, whose permissions for
other licensees extend to the entire whole, and thus
to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim
rights or contest your rights to work written entirely
by you; rather, the intent is to exercise the right to
control the distribution of derivative or collective
works based on the Program.
In addition, mere aggregation of another work not
based on the Program with the Program (or with a
work based on the Program) on a volume of a
storage or distribution medium does not bring the
other work under the scope of this License.
3. You may copy and distribute the Program (or a work
based on it, under Section 2) in object code or
executable form under the terms of Sections 1 and 2
above provided that you also do one of the following:
a) Accompany it with the complete corresponding
machine-readable source code, which must be
distributed under the terms of Sections 1 and 2
above on a medium customarily used for software
interchange; or,
b) Accompany it with a written offer, valid for at least
three years, to give any third party, for a charge no
more than your cost of physically performing source
distribution, a complete machine-readable copy of
the corresponding source code, to be distributed
under the terms of Sections 1 and 2 above on a

medium customarily used for software interchange;
or,
c) Accompany it with the information you received as
to the offer to distribute corresponding source code.
(This alternative is allowed only for noncommercial
distribution and only if you received the program in
object code or executable form with such an offer,
in accord with Subsection b above.)
The source code for a work means the preferred
form of the work for making modifications to it. For
an executable work, complete source code means
all the source code for all modules it contains, plus
any associated interface definition files, plus the
scripts used to control compilation and installation
of the executable. However, as a special exception,
the source code distributed need not include
anything that is normally distributed (in either
source or binary form) with the major components
(compiler, kernel, and so on) of the operating system
on which the executable runs, unless that
component itself accompanies the executable.
If distribution of executable or object code is made
by offering access to copy from a designated place,
then offering equivalent access to copy the source
code from the same place counts as distribution of
the source code, even though third parties are not
compelled to copy the source along with the object
code.
WHAT'S ON THE CD-ROM
C

6516922 AppC.F 9/26/02 11:41 AM Page 277
4. You may not copy, modify, sublicense, or distribute the
Program except as expressly provided under this
License. Any attempt otherwise to copy, modify,
sublicense or distribute the Program is void, and will
automatically terminate your rights under this License.
However, parties who have received copies, or rights,
from you under this License will not have their licenses
terminated so long as such parties remain in full
compliance.
5. You are not required to accept this License, since you
have not signed it. However, nothing else grants you
permission to modify or distribute the Program or its
derivative works. These actions are prohibited by law if
you do not accept this License. Therefore, by modifying
or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License
to do so, and all its terms and conditions for copying,
distributing or modifying the Program or works based
on it.
6. Each time you redistribute the Program (or any work
based on the Program), the recipient automatically
receives a license from the original licensor to copy,
distribute or modify the Program subject to these terms
and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights
granted herein. You are not responsible for enforcing
compliance by third parties to this License.
7. If, as a consequence of a court judgment or allegation
of patent infringement or for any other reason (not

limited to patent issues), conditions are imposed on
you (whether by court order, agreement or otherwise)
that contradict the conditions of this License, they do
not excuse you from the conditions of this License. If
you cannot distribute so as to satisfy simultaneously
your obligations under this License and any other
pertinent obligations, then as a consequence you may
not distribute the Program at all. For example, if a
patent license would not permit royalty-free
redistribution of the Program by all those who receive
copies directly or indirectly through you, then the only
way you could satisfy both it and this License would be
to refrain entirely from distribution of the Program.
If any portion of this section is held invalid or
unenforceable under any particular circumstance, the
balance of the section is intended to apply and the
section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to
infringe any patents or other property right claims or to
contest validity of any such claims; this section has the
sole purpose of protecting the integrity of the free
software distribution system, which is implemented by
public license practices. Many people have made
generous contributions to the wide range of software
distributed through that system in reliance on
consistent application of that system; it is up to the
author/donor to decide if he or she is willing to
distribute software through any other system and a
licensee cannot impose that choice.

This section is intended to make thoroughly clear what
is believed to be a consequence of the rest of this
License.
8. If the distribution and/or use of the Program is
restricted in certain countries either by patents or by
copyrighted interfaces, the original copyright holder
who places the Program under this License may add an
explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in
or among countries not thus excluded. In such case,
this License incorporates the limitation as if written in
the body of this License.
9. The Free Software Foundation may publish revised
and/or new versions of the General Public License from
time to time. Such new versions will be similar in spirit
to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If
the Program specifies a version number of this License
which applies to it and "any later version", you have the
option of following the terms and conditions either of
that version or of any later version published by the
Free Software Foundation. If the Program does not
specify a version number of this License, you may
choose any version ever published by the Free
Software Foundation.
10. If you wish to incorporate parts of the Program into
other free programs whose distribution conditions are
different, write to the author to ask for permission. For
software which is copyrighted by the Free Software

Foundation, write to the Free Software Foundation; we
sometimes make exceptions for this. Our decision will
be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting
the sharing and reuse of software generally.
278
APPENDIX
6516922 AppC.F 9/26/02 11:41 AM Page 278
279
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF
CHARGE, THERE IS NO WARRANTY FOR THE
PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED
IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE PROGRAM "AS IS"
WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE PROGRAM IS WITH YOU.
SHOULD THE PROGRAM PROVE DEFECTIVE, YOU
ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW
OR AGREED TO IN WRITING WILL ANY COPYRIGHT
HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE PROGRAM AS
PERMITTED ABOVE, BE LIABLE TO YOU FOR

DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
INCIDENTAL OR CONSEQUENTIAL DAMAGES
ARISING OUT OF THE USE OR INABILITY TO USE THE
PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS
OF DATA OR DATA BEING RENDERED INACCURATE
OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
OR A FAILURE OF THE PROGRAM TO OPERATE WITH
ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR
OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
WHAT'S ON THE CD-ROM
C
6516922 AppC.F 9/26/02 11:41 AM Page 279
280
INDEX
Symbols
& (ampersand), 16
' (apostrophe), 161
* (asterisk), 7, 89, 124, 208, 243
@ (at symbol), 154, 208, 212, 216, 242
\ (backslash), 156, 159, 161
^ (caret), 243
, (comma), 57, 111, 159
$ (dollar sign), 243
" (double quotes), 161, 242
= (equal sign), 37
/ (forward slash), 33, 38
() (parentheses), 36, 42, 44, 57
% (percent sign), 34, 40, 114, 142, 152, 208

. (period), 33, 35, 38, 243
+ (plus sign), 243
? (question mark), 243
; (semicolon), 18, 24, 29, 35
' (single quote), 242
[] (square brackets), 242
_ (underscore), 33, 34, 40, 114, 142
A
aborted_clients variable, 197
aborted_connects variable, 197
ABS function, 134, 139
Access (Microsoft), 5, 166–167
ACOS function, 135
action attribute, 239
ActivePerl, 246–247
ActiveState, 246, 248
ADD COLUMN command, 54
ADD INDEX command, 55, 58–61
ADD PRIMARY KEY command, 55, 69
ADD UNIQUE clause, 202
ADDATE (DATE_ADD) function, 149
addition (+) operator, 134, 219, 242
administration tools, 174–175
Administrator accounts, 181, 214
AFTER keyword, 56, 57, 66
AIX, 5, 9
aliases
assign, 145
described, 113
retrieve data from multiple

tables with, 129
ALL keyword, 208, 209
ALTER privilege, 209
ALTER TABLE command
add columns with, 56–57, 62, 64–65, 106
add indexes with, 58–60, 202
add primary keys with, 60–61
change column types with, 68–69
delete columns with, 70–71
delete indexes with, 72–73
described, 54–55
improve performance with, 189
multiple operations with, 73
rename columns with, 66–67
rename tables with, 74
security and, 209
syntax of, 54
TYPE= option, 75
American Standard Code for Information
Interchange. See ASCII text files
ampersand (&), 16
AND keyword, 105, 111
AND operator, 116–117
ANSI (American National Standards
Institute), 6
Apache Web server. See also servers
compatibility of, with MySQL, 3
Perl and, 242, 245, 247
PHP and, 218, 220–221, 229
apostrophe ('), 161

arithmetic operators, 134, 219, 242
arrays, 218, 242
AS keyword, 113, 129, 145
ASC keyword, 77, 93, 111
ASCII (American Standard Code for
Information Interchange) text
files, 133, 141. See also text files
ASCII function, 141
ASIN function, 135
asterisk (*), 7, 89, 124, 208, 243
at symbol (@), 154, 208, 212, 216, 242
ATAN function, 135
authentication, 207
auto-increment columns. See also
AUTO_INCREMENT attribute; columns
add, 64–65
described, 43, 82–83
integers and, 64
PHP and, 235
primary keys and, 64
sequential numbers for, 83
AUTO_INCREMENT attribute, 37, 43,
64–65, 75, 82–83. See also
auto-increment columns
averages, calculate, 109, 126–127
AVG function, 126–127
AVG_ROW_LENGTH option, 37, 41
B
back_log variable, 195
backslash (\), 156, 159, 161

backup(s)
automated, 170–171
DROP DATABASE command and, 32
DROP TABLE command and, 52
importance of, 30
mysqldump utility and, 157, 168–169
restore files from, 157, 169
table structure, 172, 173
BDB (Berkeley DB) tables, 31, 75
bench directory, 15
benchmark utilities, 10, 11, 15
BIGINT column type, 42
bin directory, 15, 17, 184
binary log files, 201. See also log files
binary operators, 155
binary versions
of MySQL, 8–9, 11, 13
of PHP, 220–221
BIT_AND (bitwise AND) function, 127
BIT_COUNT function, 155
BIT_OR (bitwise OR) function, 127
BLOB (Binary Large Object)
column type, 44, 188
<br> tag, 251
bytes
described, 42, 258
SET columns and, 49
bytes_received variable, 197
bytes_sent variable, 197
C

caret (^), 243
case-sensitivity, of commands, 19
CEILING function, 135
central processing units. See CPUs
6516922 Index.F 9/26/02 11:41 AM Page 280
281
MYSQL:
Your visual blueprint to open
source database management
CGI (Common Gateway Interface), 229,
245, 251, 256
CGI.pm, 256
CHANGE command, 54, 66–68
CHAR column type, 36, 38–39, 44,
46–47, 56
CHAR function, 141
CHAR_LENGTH function, 140
CHARACTER_LENGTH function, 140
CHECK TABLE command, 193
CHECKSUM option, 37
checksums, 37, 155
CLEAR command, 24, 25
client(s)
configuration options and, 28–29, 194
described, 258
security and, 206
-server systems, 2, 18
software for, 3
column(s). See also auto-increment
columns; fields

add, 54, 56–57, 62, 64–65, 106
attributes of, 36, 43
copy, 37
default values for, 43
delete, 54, 70
described, 2, 4, 258
fixed-length, 44, 56
increment values of, 108–109
modify, 54
names, 56, 66–67, 76
plan, 30
specify, 36, 80, 110, 111
types
described, 42–43
change, 68–69
table design and, 188
update, 97, 104–109
variable-length, 37, 44, 46, 188
width, 43, 63
combine conditions, 111
comma (,), 57, 111, 159
comma-delimited files, 133
command(s). See also specific commands
case-sensitivity of, 19
clear, 24–25
described, 4, 6
display list of, 18, 19, 25
edit, 25, 26–27
execute, 25, 26–27
save changes to, 26

COMMENT keyword, 75
comments, 75
COMMIT command, 31
Common Gateway Interface. See CGI
comparison
functions, 134
operators, 111, 138–139
compile process, 10, 12–13
Comprehensive Perl Archive Network.
See CPAN
CONCAT function, 113, 140, 144
CONCAT_WS function, 140
concatenation (.) operator, 219, 242
CONCURRENT option, 156, 162
concurrent_inserts variable, 195
conditional statements, 219, 243.
See also conditions
conditions. See also conditional
statements
described, 258
select multiple, 116–117
configuration files, 194–195, 198–199
configure command, 220
configure program, 12–13
CONNECT command, 25
connect method, 250, 254
connect_timeout variable, 195
CONNECTION_ID function, 154
connections variable, 197
content, format and, separation of, 3

conversion functions, 141
copy
columns, 37
data between tables, 157
table structure, 173
COS function, 135
COT function, 135
COUNT function, 124, 126–127
CPAN (Comprehensive Perl
Archive Network), 244
CPUs (central processing units), 71, 188
CREATE command, 21, 174
CREATE DATABASE command,
6, 21, 32–33
CREATE INDEX command, 59
CREATE TABLE command
create archive tables with, 95
described, 6, 36–39
indexed tables and, 50, 61
INSERT command and, 79
multiple-line queries and, 24
security and, 209
text columns and, 46
TYPE keyword and, 31
cron utility, 170
CURDATE function, 148
CURTIME function, 148
D
daemon, 16
data

column types, 44–45
critical and non-critical,
separation of, 30
export, 156–158, 164–167
import, 156–157, 160–161, 167
size, reduce, 188
sort, 55, 93, 111, 120–121, 189
data directory, 15
database(s). See also DBMSs (database
management systems)
count rows in, 124–125
create, 6, 21, 30–33
delete, 6, 32, 52–53
described, 2–4, 258
design basics, 30–31
driver modules (DBD), 247, 248, 249
lists of available, 6, 19, 34
security for, 206
select, 6, 25, 35
size information, 226
view current, 20, 175
DATABASE function, 154
Databases tab, 184
date(s). See also times
add/subtract, 149, 153
column types, 45
components, 148
delete data by, 94–95
display, 152
format, 149, 151

functions, 148–149
get current, 148
work with, 150–152
6516922 Index.F 9/26/02 11:41 AM Page 281
282
INDEX
DATE function, 148–149
DATE_ADD function, 149, 153
DATE_FORMAT function, 149, 152
DATE_SUB function, 149, 153
DATETIME function, 148–149
DATETYPE column type, 45
DAY_HOUR keyword, 149
DAY_MINUTE keyword, 149
DAYNAME function, 148
DAYOFMONTH function, 148
DAYOFWEEK function, 148
DAYOFYEAR function, 148
DAY_SECOND keyword, 149
DB2 (IBM), 5
DBD (database driver) modules, 247,
248, 249
DBI modules, 247, 248–249, 253–254
DBMSs (database management systems).
See also databases
described, 5, 258
relational (RDBMSs), 2–3
specific types of, 5
DEC Alpha, 8
DEC OSF, 9

DECIMAL column type, 36, 39, 43
DECODE function, 155
DEFAULT attribute, 36
DEFAULT keyword, 43, 66, 68
DEGREES function, 135
DELAYED keyword, 81
delayed_insert_limit variable, 195
delayed_insert_timeout variable, 195
delayed_queue_size variable, 195
DELETE command
delete data by date with, 94–95
delete rows with, 90–92
described, 7, 76–77
Perl and, 252, 255
PHP and, 236–237
query syntax and, 21
security and, 209
DESC keyword, 77, 93, 111
development libraries, 10
directories
delete, 53
MySQL installation and, 12, 13, 14, 15
source, 12
switch to/from, 12
disconnect method, 250
disk access, 188
DISTINCT keyword, 125
division (/) operator, 109, 134, 219, 242
DNS (domain name system), 217
do method, 254, 255

Docs directory, 15
dollar sign ($), 243
DOS (Disk Operating System)
prompt, 16, 18
DOUBLE column type, 43
DOUBLE PRECISION column type, 43
double quotes ("), 161, 242
download
CGI.pm, 256
MySQL, 8–9, 12, 14
MySQLGUI,28
packages, 11, 221
Perl, 243, 248
RPM files, 10
server software, 3
drivers. See DBD (database driver)
modules
DROP COLUMN command, 54, 70–71
drop command, 174
DROP DATABASE command, 6, 32, 52–53
DROP INDEX command, 55, 72–73, 203
DROP PRIMARY KEY command, 55, 72–73
DROP TABLE command, 6, 37, 52–53, 209
E
echo command, 218
EDIT command, 25, 26–27, 39
EGO command, 25
else statement, 236
emacs, 160, 198
ENCLOSED BY clause, 159, 161–162

ENCODE function, 155
ENCRYPT function, 155, 224
encryption, 155, 207, 224
ENUM column type, 45, 48–49
enumerations, 48–49
Environment tab, 175
equal sign (=), 37
equal to (=) operator, 111, 115,
138, 219, 243
.err file extension, 200
Err File tab, 175, 184, 185
error(s)
check tables for, 190–191
checksums and, 37
CREATE DATABASE command
and, 32, 33
DROP TABLE command and, 37, 52
ignore, 88
import process and, 163
indexes and, 60
log files, 181, 184, 185, 200–201
MySQL monitor and, 19
MySQL server and, 179
PHP and, 233
renamed columns and, 67
repair, 190–191
"unknown column," 80
escape characters, 161
ESCAPED BY clause, 159, 161–162
Excel (Microsoft), 164–165, 225

execute method, 252, 256
EXISTS keyword, 32
EXIT command, 18, 25
EXP function, 135
EXPLAIN command, 189
exponential functions, 135
export data, 156–158, 164–167
EXTENDED keyword, 192, 193
extended-status command, 174, 175,
176, 196
eXtensible Markup Language. See XML
F
FAST keyword, 193
FAT (File Allocation Table) system, 14
fetchrow_array method, 253
fetchrow_hashref method, 253
fields. See also columns
copy, 37
create, 37
described, 2, 4
enclose, 156, 160
separate, 156
text, 46, 114
FIELDS ENCLOSED BY option, 156, 160
FIELDS ESCAPED BY option, 156
FIELDS keyword, 156, 158–159
6516922 Index.F 9/26/02 11:41 AM Page 282
283
MYSQL:
Your visual blueprint to open

source database management
FIELDS option, 159
FIELDS SEPARATED BY option, 164
FIELDS TERMINATED BY option,
156, 162
file(s)
execute commands from specified, 25
extensions, 11, 200, 218, 222, 231
systems, 14
File Transfer Protocol, 9, 163. See FTP
firewalls, 226
FIRST keyword, 54, 56, 57, 66
fixed-length columns, 44, 56
flat file databases, 5
FLOAT column type, 43
FLOOR function, 135
FLUSH command, 209
FLUSH LOGS command, 201
FLUSH PRIVILEGES command, 215
flush_time variable, 195
for loops, 219. See also loops
form(s)
create, 238–241
database search, 240–241
Perl and, 256–257
Web, 256–257
<form> tag, 238–239
forward slash (/), 33, 38
FreeBSD, 9
FROM clause, 158

FROM keyword, 40, 112, 208
FROM_DAYS function, 151
FROM_UNIXTIME function, 151
FTP (File Transfer Protocol), 9, 163
FULLTEXT keyword, 59
G
geometry functions, 135
GO command, 25, 26–27, 123
GRANT command, 23, 207–209, 216
greater than (>) operator, 111,
114–115, 138, 168, 171, 219, 243
greater than or equal to (>=)
operator, 111, 115, 139, 219, 243
GREATEST function, 134, 139–140
GROUP BY clause, 111, 122, 126–127, 189
gzip utility, 11
H
hardware requirements, 3
hashed indexes, 31
header files, 10
heap tables, 31, 75
HELP command, 18, 25
hostnames
convert, to IP addresses, 217
MySQLGUI and, 29
PHP and, 228
security and, 207
specify, 19, 22, 29, 216
view current, 20
HOUR function, 148

HOUR_MINUTE keyword, 149
HOUR_SECOND keyword, 149
HP-UX, 9
.htaccess file, 223
HTML (HyperText Markup Language)
<form> tag, 238–239
links, to MySQL download pages, 9
MySQL documentation and, 15
<p> tag, 251
PHP and, 218, 231, 238–239
Web forms and, 256–257
I
IA64 systems, 8
IBM (International Business Machines), 6
IDENTIFIED BY clause, 22, 23, 208
IF EXISTS clause, 32, 37, 52
IF keyword, 32
IF NOT EXISTS clause, 32, 33, 36
if statements
Perl and, 243, 255, 256
PHP and, 219, 233, 234, 236, 238
IGNORE keyword, 88, 97, 101, 156
IIS (Internet Information Server), 221, 247
import data, 156–157, 160–161, 167
Import Text Wizard, 167
INDEX keyword, 36, 37
indexes. See also ISAM (Indexed
Sequential Access Method) tables
add, 55, 58–59, 189, 202
create, 36, 50–51

delete, 55, 72–73, 203
described, 4, 30, 258
disadvantages of, 203
full-text, 59
improve performance with, 202–203
names of, 36, 55
PHP and, 218
primary key, 60–61
unique, 36, 59–61, 64, 72–73, 259
INNER JOIN clause, 110, 130–131
InnoDB tables, 31, 75
InnoDB Web site, 31
INSERT command
add data with, 76
add rows with, 78–79
copy data between tables with, 157
copy older data with, 95
copy table structures with, 173
described, 7
Perl and, 252, 254
PHP and, 234–236, 238
query syntax and, 21
security and, 209
specify columns for rows with, 80
specify INSERT priority for, 81
installation
compact, 14
custom, 14, 15
file systems and, 32
minimal, 10

MySQL, 8–9, 10, 12–15, 17, 32
MySQLGUI,28
Perl, 248
phpMyAdmin, 222–223
from source code, 12–13
test, 17
typical, 14, 15
INSTR function, 141, 147
INTEGER column type, 42
integers
auto-increment columns and, 64
described, 42, 258
ENUM columns and, 49
Intel, 8
interactive_timeout variable, 195
INTERVAL keyword, 149, 153
INTO keyword, 76
INTO OUTFILE option, 156, 158–159, 168
6516922 Index.F 9/26/02 11:41 AM Page 283
284
INDEX
IP (Internet Protocol) addresses,
19, 216, 217
Is equal to (=) operator, 111, 115,
138, 219, 243
Is greater than (>) operator, 111,
114–115, 138, 168, 171, 219, 243
Is greater than or equal to
(>=) operator, 111, 115, 139, 219, 243
Is less than (<) operator, 111,

114–115, 138, 219, 243
Is less than or equal to (<=)
operator, 111, 115, 138, 142, 150
Is not equal to (!=) operator, 111,
115–116, 139, 219, 243
IS NOT NULL operator, 111, 115
IS NULL operator, 111, 115
ISAM (Indexed Sequential Access
Method) tables
check, for errors, 190–191
described, 31, 75, 258
INSERT priority settings, 81
quotation marks and, 37
J
Java, 5
JOIN command, 110, 130–131, 189
join_buffer_size variable, 195
joins, 110, 130–131, 189, 258
K
key_buffer_size variable, 195
keys, described, 30, 258.
See also primary keys
kill command, 174, 175, 182
L
LAST_INSERT_ID function, 154
LEAST function, 134, 138–139
LEFT function, 140, 146
LEFT JOIN clause, 110, 131
less than (<) operator, 111,
114–115, 138, 219, 243

LIKE clause, 34, 40
LIKE keyword, 34, 40, 111, 114
LIKE operator, 114–115, 142, 195
LIMIT clause, 93, 103, 110, 77,
118–119, 189
LIMIT keyword, 96
line(s)
breaks, 163
go to specific, 24
navigate between, 24
LINES option, 159
LINES TERMINATED BY option,
156, 159, 162
Linux. See also Red Hat Linux
distributions, inclusion of MySQL with, 3
edit commands under, 26–27
install MySQL under, 8, 10–11
install server software on, 3
log files and, 201
MySQLGUI and, 28
Perl and, 243, 245
PHP and, 220
PostgreSQL,5
start MySQL server under, 16
text editors, 198
LOAD DATA command, 157, 162–164, 166
LOAD DATA INFILE command, 156
local directory, 11
LOCAL option, 156, 163
LOCATE function, 141, 147

LOCK TABLES command, 189, 204–205
.log file extension, 200
log files, 181, 184, 185, 200–201
LOG function, 135
logarithmic functions, 135
logical AND (&&) operator, 219, 243
logical bitwise AND (&)
operator, 155
logical bitwise OR (|) operator, 155
logical OR (||) operator, 219, 243
long_query_time variable, 195, 196, 200
LONGBLOB column type, 44
LONGTEXT column type, 44
loops
described, 219
for, 219
while, 230, 233, 240, 243, 253
LOW_PRIORITY keyword, 76, 81, 100,
156, 162
LOW_PRIORITY option, 90, 100, 156, 162
LOWER function, 141
LTRIM function, 141
M
Macintosh, 9, 221
mainframe computers, 5
make command, 12, 248
make install command, 12, 248, 249
make test command, 248, 249
math functions, 134–137
MAX function, 126–127

max_allowed_packet variable, 195
max_concurrent_users variable, 196
max_connect_errors variable, 195
max_connections variable, 195
max_deployed_threads variable, 195
max_join_size variable, 195
MAX_ROWS option, 37, 75
max_sort_length variable, 195
max_user_connections variable,
195, 196
MD5 checksums, 155
MD5 function, 155
MEDIUM keyword, 193
MEDIUMBLOB column type, 44
MEDIUMINT column type, 42
MEDIUMTEXT column type, 44
memory, 31, 42, 71, 75, 188
Microsoft Access, 5, 166–167
Microsoft Excel, 164–165, 225
Microsoft Internet Information
Server (IIS), 221, 247
Microsoft SQL Server, 5
Microsoft Windows. See Windows
(Microsoft)
MID function, 140, 146
MIN function, 126–127
Mini SQL. See mSQL (Hugh
Technologies)
MIN_ROWS option, 37, 75
MINUTE function, 148

MINUTE_SECOND keyword, 149
mod_perl module, 242, 245, 247
MODIFY command, 54, 68
MODIFY keyword, 68
modulo (%) operator, 134, 219, 242
MONTH function, 148, 150
MONTHNAME function, 148
mSQL (Hugh Technologies), 5
multiple-line queries, 24–27
6516922 Index.F 9/26/02 11:41 AM Page 284
285
MYSQL:
Your visual blueprint to open
source database management
multiplication (*) operator, 134,
219, 242
multitasking systems, 14
my.cnf, 23, 194, 199
my.ini, 15, 175, 184–185, 194, 199
my.ini Setup tab, 175, 184, 199
MyISAM tables, 31, 36, 75, 81, 92, 190–191
myisamchk, 190–194
MySQL client, 4, 6. See also clients
mysql command, 18–19, 157, 177
mysql directory, 15, 16
MySQL monitor
backups and, 169
classification of, as a client, 3, 18
clear commands with, 24
configuration options and, 194

described, 6, 18–21, 259
edit commands with, 25, 26–27
exit, 19, 25
start, 18, 19
test queries with, 21
use commands from, 6
view server status with, 20
MySQL server. See also servers
auto-increment columns and, 82
backups and, 157, 171
column types and, 43
configuration options, 15, 194–195
connect to, 27, 228–229, 250–251
delete actions and, 90, 92, 93
described, 4, 259
IGNORE option and, 101
installation and, 12
MySQLGUI and, 132, 186–187
optimize, 188–189
passwords and, 194
performance information, 196–197
PHP and, 218, 226–227
reports, 175, 185
startup, 16–17, 174, 178–181, 217
status information, 20, 175–176, 195, 226
stop, 16–17, 174, 178–181
table types and, 75
text columns and, 47
troubleshoot, 188–189
TRUNCATE option and, 92

UPDATE command and, 96, 107
usernames, 194
version information, 20, 177
MySQL Web site, 3, 8, 11–12, 14, 132, 248
mysqladmin
configuration options and, 194
described, 174
display processes with, 182–183
display variables with, 17, 195–196
extended-status command, 202
flush-privileges command, 215
kill processes with, 175, 182, 183
password command, 210
ping command, 179
processlist command, 174, 182–184
security and, 209
shutdown command, 174, 178, 180, 209
start/stop MySQL server with, 181–182
status command, 17, 175, 176, 184
test MySQL installation with, 17
version command, 177
mysql_affected_rows function,
236–237
MySQL-bench-version-i386.rpm, 10
MySQL-client-version-i386.rpm, 10
mysql_close command, 228
mysql_connect function, 228, 231,
233, 234, 235
mysqld command, 174, 178, 180
MySQL-devel-version.i386.rpm, 10

mysqld-max,16
mysqldump, 157, 168–172
mysql.err, 181
mysql_fetch_assoc function, 232
mysql_fetch_object function,
232, 233, 240, 241
mysql_fetch_row function, 230, 232
MySQLGUI
classification of, as a client, 3
configure, 28–29
described, 27
display data with, 132–133
edit queries with, 29
exit, 29
manage MySQL server with, 186–187
query syntax and, 29
send queries with, 187
start, 28
mysql_insert_id function, 235
MySQLManager.exe, 15
MySQL-MAX package, 9, 31, 75
mysql_num_rows function, 241
mysql_pconnect function, 229
mysql_query function, 230, 231,
233–234, 236–237, 240
mysql_select_db function, 230, 231,
233, 234
mysql.server script, 16
mysqlshow utility, 34
MySQL-version-i386.rpm, 10

N
NATURAL JOIN clause, 130–131
NATURAL LEFT JOIN clause, 131
NET START command, 174, 180
NET STOP command, 174, 180
net_buffer_length variable, 195
net_read_timeout variable, 195
NetWare (Novell), 221
Network control panel, 14
network security, 206, 216
net_write_timeout variable, 195
newline (\n) character, 156, 161
not equal to (<>) operator, 111,
115, 139
NOT keyword, 32, 111
NOT LIKE keyword, 111
NOT LIKE operator, 114–116, 142
NOT NULL attribute, 36, 37, 43, 55, 64
NOT operator, 116–117
Notepad, 27, 160, 199
Novell NetWare, 221
NOW function, 148, 152
ntbackup.exe, 171
NTFS (New Technology File System), 14
NULL attribute, 36, 43, 45, 68, 69.
See also null values
null values. See also NULL attribute
described, 259
special characters for, 161
timestamp columns and, 84, 85

numeric column types, 42–43
numeric comparisons, 111, 138–139
O
objects, store query results as, 232–233
Office (Microsoft). See Microsoft Access;
Microsoft Excel
ON keyword, 59, 131, 208
6516922 Index.F 9/26/02 11:41 AM Page 285
286
INDEX
open tables status indicator, 20
opened_tables variable, 197
open_files variable, 197
open_tables variable, 197
opens status indicator, 20
operator(s). See also specific operators
arithmetic, 134, 219, 242
binary, 155
comparison, 111, 138–139
PHP and, 219
precedence, 137
OPTIMIZE TABLE command, 192–193
OR keyword, 105, 111
OR operator, 116–117
Oracle, 5
ORDER BY clause
described, 35, 77, 111
eliminate, 189
EXPLAIN command and, 189
LIMIT clause and, 118–119

sort data with, 120–121
P
<p> tag, 251
packages, 8, 10–11, 13, 201, 244–245
paged output, specify programs to use, 25
PAGER command, 25
parentheses ( ), 36, 42, 44, 57
password(s). See also security
authentication of, 207
backups and, 157
configuration options and, 194
encryption of, 155, 207
guidelines for, 206, 211
modify, 23, 174, 210–211, 215
MySQL monitor and, 18, 19, 22–23
MySQL server and, 132
MySQLGUI and, 28
PHP and, 223, 228
root user, 23, 207
specify, 18, 19, 22, 23, 211
password command, 174
PASSWORD function, 155, 211
percent sign (%), 34, 40
period (.), 33, 35, 38, 243
Perl
connect to MySQL server with, 250–251
customize MySQL clients with, 4
DBD (database driver) modules,
247, 248, 249
DBI modules, 247, 248–249, 253, 254

delete records with, 255
described, 3, 242–243, 259
display query results with, 252–253
flat-file databases and, 5
insert records with, 254
install, 243–248
interpreter, 242
LIMIT clause and, 119
MySQL installation and, 10, 12
operators, 242
SELECT command and, 113
Web forms and, 256–257
persistent connections, 229
PHP
add records with, 238–239
delete records with, 236–237
described, 3–4, 218–219, 259
display query results with, 230–231
forms and, 238–241
HTML and, 218
insert records from, 234–235
installation, 220–221
LIMIT clause and, 119
SELECT command and, 113
store query results as objects with,
232–233
Web site, 220, 221
.php file extension, 218, 222, 231
.php3 file extension, 218, 222, 231
phpinfo command, 220

phpMyAdmin, 222–227
physical security, 206. See also security
PI function, 135
pico text editor, 26–27, 160, 198
ping command, 174, 176, 179
plus sign (+), 243
POSIX regular expression standard, 143
PostgreSQL, 5
POWER function, 135
PPM (Perl Package Manager), 248
prepare method, 252, 256
primary keys
add, 55
auto-increment columns and, 64
create, 37
define, 50–51
delete, 55, 72–73
described, 4, 30, 37, 259
indexes and, 4, 60–61
update, 97
PRINT command, 25
print statement, 251, 252
print_bold function, 219
priority settings, 76, 81, 100, 156, 162
privileges. See also security
described, 207, 259
grant, 207, 208–209
PHP and, 234
remove, 216
storage of, in security tables, 214–215

view, 212–213
Process tab, 175, 184
processes. See also threads
described, 183
kill, 182, 183
view/manage, 182–183
processlist command, 174, 182–184
processors, 71, 188
programming languages, described, 3.
See also specific languages
ps command, 183
Q
QUARTER function, 148
queries. See also specific commands
client-server systems and, 2
described, 2, 4, 259
edit long, 26–27
multiple-line, 24–27
per second measure, 20
slow, 20, 197
specify, 24–25
syntax for, 18, 21, 24, 29, 189
question mark (?), 243
questions variable, 197
QUICK keyword, 192, 193
QUICK option, 90, 192, 193
R
RADIANS function, 135
RAM (random-access memory).
See memory

6516922 Index.F 9/26/02 11:41 AM Page 286

×