summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <jcole@tetra.spaceapes.com>2001-08-01 15:17:39 -0500
committerunknown <jcole@tetra.spaceapes.com>2001-08-01 15:17:39 -0500
commitef049e69fa0c082be39fec1c3c79dedc78049a13 (patch)
tree52c5a32004814f412135edd6bad8c62b13796623
parent9563e658c986be854453215d22c7e090c4132df6 (diff)
downloadmariadb-git-ef049e69fa0c082be39fec1c3c79dedc78049a13.tar.gz
DocTOC Chapter 4 Complete!
-rw-r--r--Docs/manual.texi15429
1 files changed, 7887 insertions, 7542 deletions
diff --git a/Docs/manual.texi b/Docs/manual.texi
index 230f73e5804..aa3e03c3b2d 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -113,15 +113,12 @@ distribution for that version.
* Introduction:: General Information about @strong{MySQL}
* Installing:: Installing @strong{MySQL}
* Tutorial:: @strong{MySQL} Tutorial
-* Privilege system:: The @strong{MySQL} access privilege system
+* MySQL Database Administration::
* Reference:: @strong{MySQL} language reference
* Table types:: @strong{MySQL} table types
-* Server:: @strong{MySQL} Server
-* Replication:: Replication
* Fulltext Search:: Fulltext Search
* Performance:: Getting maximum performance from @strong{MySQL}
* MySQL Benchmarks:: The @strong{MySQL} benchmark suite
-* Tools:: @strong{MySQL} Utilities
* Maintenance:: Maintaining a @strong{MySQL} installation
* Adding functions:: Adding new functions to @strong{MySQL}
* Adding procedures:: Adding new procedures to @strong{MySQL}
@@ -129,7 +126,6 @@ distribution for that version.
* Common programs:: Using @strong{MySQL} with some common programs
* Problems:: Problems
* Common problems:: Solving some common problems with @strong{MySQL}
-* Log files::
* Clients:: @strong{MySQL} client tools and APIs
* MySQL internals:: @strong{MySQL} internals
* Environment variables:: @strong{MySQL} environment variables
@@ -11856,7 +11852,7 @@ We are interested in finding someone to do a port, and we will help them
with any technical questions they may have while doing the port.
-@node Tutorial, Privilege system, Installing, Top
+@node Tutorial, MySQL Database Administration, Installing, Top
@chapter Introduction to MySQL: A MySQL Tutorial
@cindex tutorial
@@ -14284,8 +14280,682 @@ FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\'
@end example
-@node Privilege system, Reference, Tutorial, Top
-@chapter The MySQL Access Privilege System
+@node MySQL Database Administration, Reference, Tutorial, Top
+@chapter MySQL Database Administration
+
+@menu
+* Configuring MySQL::
+* Installing many servers::
+* Privilege system::
+* User Account Management::
+* Disaster Prevention::
+* Database Administration::
+* KILL::
+* Localization::
+* Server-Side Scripts::
+* Client-Side Scripts::
+* perror::
+* Batch Commands::
+* Log Files::
+* Log file maintenance::
+* Replication::
+* Replication HOWTO::
+@end menu
+
+
+@node Configuring MySQL, Installing many servers, MySQL Database Administration, MySQL Database Administration
+@section Configuring MySQL
+
+
+@menu
+* Command-line options::
+* Option files::
+@end menu
+
+@node Command-line options, Option files, Configuring MySQL, Configuring MySQL
+@subsection mysqld Command-line Options
+
+@findex command-line options
+@cindex options, command-line
+@cindex mysqld options
+
+@code{mysqld} accepts the following command-line options:
+
+@table @code
+@item --ansi
+Use ANSI SQL syntax instead of MySQL syntax. @xref{ANSI mode}.
+
+@item -b, --basedir=path
+Path to installation directory. All paths are usually resolved relative to
+this.
+
+@item --big-tables
+Allow big result sets by saving all temporary sets on file. It solves
+most 'table full' errors, but also slows down the queries where
+in-memory tables would suffice. Since Version 3.23.2, @strong{MySQL} is
+able to solve it automatically by using memory for small temporary
+tables and switching to disk tables where necessary.
+
+@item --bind-address=IP
+IP address to bind to.
+
+@item --character-sets-dir=path
+Directory where character sets are. @xref{Character sets}.
+
+@item --chroot=path
+Chroot @code{mysqld} daemon during startup. Recommended security measure. It will
+somewhat limit @code{LOAD DATA INFILE} and @code{SELECT ... INTO OUTFILE}
+though.
+
+@item --core-file
+Write a core file if @code{mysqld} dies. For some systems you must also
+specify @code{--core-file-size} to @code{safe_mysqld}. @xref{safe_mysqld, ,
+@code{safe_mysqld}}.
+
+@item -h, --datadir=path
+Path to the database root.
+
+@item --default-character-set=charset
+Set the default character set. @xref{Character sets}.
+
+@item --default-table-type=type
+Set the default table type for tables. @xref{Table types}.
+
+@item --debug[...]=
+If @strong{MySQL} is configured with @code{--with-debug}, you can use this
+option to get a trace file of what @code{mysqld} is doing.
+@xref{Making trace files}.
+
+@item --delay-key-write-for-all-tables
+Don't flush key buffers between writes for any @code{MyISAM} table.
+@xref{Server parameters}.
+
+@item --enable-locking
+Enable system locking. Note that if you use this option on a system
+which a not fully working lockd() (as on Linux) you will easily get
+mysqld to deadlock.
+
+@item -T, --exit-info
+This is a bit mask of different flags one can use for debugging the
+mysqld server; One should not use this option if one doesn't know
+exactly what it does!
+
+@item --flush
+Flush all changes to disk after each SQL command. Normally @strong{MySQL}
+only does a write of all changes to disk after each SQL command and lets
+the operating system handle the syncing to disk.
+@xref{Crashing}.
+
+@item -?, --help
+Display short help and exit.
+
+@item --init-file=file
+Read SQL commands from this file at startup.
+
+@item -L, --language=...
+Client error messages in given language. May be given as a full path.
+@xref{Languages}.
+
+@item -l, --log[=file]
+Log connections and queries to file. @xref{Query log}.
+
+@item --log-isam[=file]
+Log all ISAM/MyISAM changes to file (only used when debugging ISAM/MyISAM).
+
+@item --log-slow-queries[=file]
+Log all queries that have taken more than @code{long_query_time} seconds to
+execute to file. @xref{Slow query log}.
+
+@item --log-update[=file]
+Log updates to @code{file.#} where @code{#} is a unique number if not given.
+@xref{Update log}.
+
+@item --log-long-format
+Log some extra information to update log. If you are using
+@code{--log-slow-queries} then queries that are not using indexes are logged
+to the slow query log.
+
+@item --low-priority-updates
+Table-modifying operations (@code{INSERT}/@code{DELETE}/@code{UPDATE})
+will have lower priority than selects. It can also be done via
+@code{@{INSERT | REPLACE | UPDATE | DELETE@} LOW_PRIORITY ...} to lower
+the priority of only one query, or by
+@code{SET OPTION SQL_LOW_PRIORITY_UPDATES=1} to change the priority in one
+thread. @xref{Table locking}.
+
+@item --memlock
+Lock the @code{mysqld} process in memory. This works only if your
+system supports the @code{mlockall()} system call (like Solaris). This
+may help if you have a problem where the operating system is causing
+@code{mysqld} to swap on disk.
+
+@item --myisam-recover [=option[,option...]]] where option is one of DEFAULT, BACKUP, FORCE or QUICK.
+If this option is used, @code{mysqld} will on open check if the table is
+marked as crashed or if if the table wasn't closed properly. (The last
+option only works if you are running with @code{--skip-locking}). If this
+is the case @code{mysqld} will run check on the table. If the table was corrupted,
+@code{mysqld} will attempt to repair it.
+
+The following options affects how the repair works.
+
+@multitable @columnfractions .3 .7
+@item DEFAULT @tab The same as not giving any option to
+ @code{--myisam-recover}.
+@item BACKUP @tab If the data table was changed during recover, save a
+ backup of the @file{table_name.MYD} data file as
+ @file{table_name-datetime.BAK}.
+@item FORCE @tab Run recover even if we will loose more than one row
+ from the .MYD file.
+@item QUICK @tab Don't check the rows in the table if there isn't any
+ delete blocks.
+@end multitable
+
+Before a table is automatically repaired, @strong{MySQL} will add a note
+about this in the error log. If you want to be able to recover from most
+things without user intervention, you should use the options
+@code{BACKUP,FORCE}. This will force a repair of a table even if some rows
+would be deleted, but it will keep the old data file as a backup so that
+you can later examine what happened.
+
+@item --pid-file=path
+Path to pid file used by @code{safe_mysqld}.
+
+@item -P, --port=...
+Port number to listen for TCP/IP connections.
+
+@item -o, --old-protocol
+Use the 3.20 protocol for compatibility with some very old clients.
+@xref{Upgrading-from-3.20}.
+
+@item --one-thread
+Only use one thread (for debugging under Linux). @xref{Debugging server}.
+
+@item -O, --set-variable var=option
+Give a variable a value. @code{--help} lists variables. You can find a full
+description for all variables in the @code{SHOW VARIABLES} section in this
+manual. @xref{SHOW VARIABLES}. The tuning server parameters section includes
+information of how to optimize these. @xref{Server parameters}.
+
+@item --safe-mode
+Skip some optimize stages. Implies @code{--skip-delay-key-write}.
+
+@item --safe-show-database
+Don't show databases for which the user doesn't have any privileges.
+
+@item --secure
+IP numbers returned by the @code{gethostbyname()} system call are
+checked to make sure they resolve back to the original hostname. This
+makes it harder for someone on the outside to get access by pretending
+to be another host. This option also adds some sanity checks of
+hostnames. The option is turned off by default in @strong{MySQL} Version 3.21
+because sometimes it takes a long time to perform backward resolutions.
+@strong{MySQL} Version 3.22 caches hostnames (unless @code{--skip-host-cache}
+is used) and has this option enabled by default.
+
+@item --skip-concurrent-insert
+Turn off the ability to select and insert at the same time on @code{MyISAM}
+tables. (This is only to be used if you think you have found a bug in this
+feature).
+
+@item --skip-delay-key-write
+Ignore the @code{delay_key_write} option for all tables.
+@xref{Server parameters}.
+
+@item --skip-grant-tables
+This option causes the server not to use the privilege system at all. This
+gives everyone @emph{full access} to all databases! (You can tell a running
+server to start using the grant tables again by executing @code{mysqladmin
+flush-privileges} or @code{mysqladmin reload}.)
+
+@item --skip-host-cache
+Never use host name cache for faster name-ip resolution, but query DNS server
+on every connect instead. @xref{DNS}.
+
+@item --skip-locking
+Don't use system locking. To use @code{isamchk} or @code{myisamchk} you must
+shut down the server. @xref{Stability}. Note that in @strong{MySQL} Version
+3.23 you can use @code{REPAIR} and @code{CHECK} to repair/check @code{MyISAM}
+tables.
+
+@item --skip-name-resolve
+Hostnames are not resolved. All @code{Host} column values in the grant tables
+must be IP numbers or @code{localhost}. @xref{DNS}.
+
+@item --skip-networking
+Don't listen for TCP/IP connections at all. All interaction with
+@code{mysqld} must be made via Unix sockets. This option is highly
+recommended for systems where only local requests are allowed. @xref{DNS}.
+
+@item --skip-new
+Don't use new, possible wrong routines. Implies @code{--skip-delay-key-write}.
+This will also set default table type to @code{ISAM}. @xref{ISAM}.
+
+@item --skip-symlink
+Don't delete or rename files that a symlinked file in the data directory
+points to.
+
+@item --skip-safemalloc
+If @strong{MySQL} is configured with @code{--with-debug=full}, all programs
+will check the memory for overruns for every memory allocation and memory
+freeing. As this checking is very slow, you can avoid this, when you don't
+need memory checking, by using this option.
+
+@item --skip-show-database
+Don't allow 'SHOW DATABASE' commands, unless the user has @strong{process}
+privilege.
+
+@item --skip-stack-trace
+Don't write stack traces. This option is useful when you are running
+@code{mysqld} under a debugger. @xref{Debugging server}.
+
+@item --skip-thread-priority
+Disable using thread priorities for faster response time.
+
+@item --socket=path
+Socket file to use for local connections instead of default
+@code{/tmp/mysql.sock}.
+
+@item transaction-isolation= @{ READ-UNCOMMITTED | READ-COMMITTED | REPEATABLE-READ | SERIALIZABLE @}
+Sets the default transaction isolation level. @xref{SET TRANSACTION}.
+
+@item -t, --tmpdir=path
+Path for temporary files. It may be useful if your default @code{/tmp}
+directory resides on a partition too small to hold temporary tables.
+
+@item -u, --user=user_name
+Run @code{mysqld} daemon as user @code{user_name}. This option is
+@emph{mandatory} when starting @code{mysqld} as root.
+
+@item -V, --version
+Output version information and exit.
+
+@item -W, --warnings
+Print out warnings like @code{Aborted connection...} to the @code{.err} file.
+@xref{Communication errors}.
+@end table
+
+
+@node Option files, , Command-line options, Configuring MySQL
+@subsection my.cnf Option Files
+
+@cindex default options
+@cindex option files
+@cindex creating, default startup options
+@cindex startup options, default
+
+@strong{MySQL} can, since Version 3.22, read default startup options for the
+server and for clients from option files.
+
+@strong{MySQL} reads default options from the following files on Unix:
+
+@tindex .my.cnf file
+@multitable @columnfractions .3 .7
+@item @strong{Filename} @tab @strong{Purpose}
+@item @code{/etc/my.cnf} @tab Global options
+@item @code{DATADIR/my.cnf} @tab Server-specific options
+@item @code{defaults-extra-file} @tab The file specified with --defaults-extra-file=#
+@item @code{~/.my.cnf} @tab User-specific options
+@end multitable
+
+@code{DATADIR} is the @strong{MySQL} data directory (typically
+@file{/usr/local/mysql/data} for a binary installation or
+@file{/usr/local/var} for a source installation). Note that this is the
+directory that was specified at configuration time, not the one specified
+with @code{--datadir} when @code{mysqld} starts up! (@code{--datadir} has no
+effect on where the server looks for option files, because it looks for them
+before it processes any command-line arguments.)
+
+@strong{MySQL} reads default options from the following files on Windows:
+
+@multitable @columnfractions .3 .7
+@item @strong{Filename} @tab @strong{Purpose}
+@item @code{windows-system-directory\my.ini} @tab Global options
+@item @code{C:\my.cnf} @tab Global options
+@item @code{C:\mysql\data\my.cnf} @tab Server-specific options
+@end multitable
+
+Note that on Windows, you should specify all paths with @code{/} instead of
+@code{\}. If you use @code{\}, you need to specify this twice, as
+@code{\} is the escape character in @strong{MySQL}.
+
+@cindex Environment variables
+@strong{MySQL} tries to read option files in the order listed above. If
+multiple option files exist, an option specified in a file read later takes
+precedence over the same option specified in a file read earlier. Options
+specified on the command line take precedence over options specified in any
+option file. Some options can be specified using environment variables.
+Options specified on the command line or in option files take precedence over
+environment variable values. @xref{Environment variables}.
+
+The following programs support option files: @code{mysql},
+@code{mysqladmin}, @code{mysqld}, @code{mysqldump}, @code{mysqlimport},
+@code{mysql.server}, @code{myisamchk}, and @code{myisampack}.
+
+You can use option files to specify any long option that a program supports!
+Run the program with @code{--help} to get a list of available options.
+
+An option file can contain lines of the following forms:
+
+@table @code
+@item #comment
+Comment lines start with @samp{#} or @samp{;}. Empty lines are ignored.
+
+@item [group]
+@code{group} is the name of the program or group for which you want to set
+options. After a group line, any @code{option} or @code{set-variable} lines
+apply to the named group until the end of the option file or another group
+line is given.
+
+@item option
+This is equivalent to @code{--option} on the command line.
+
+@item option=value
+This is equivalent to @code{--option=value} on the command line.
+
+@item set-variable = variable=value
+This is equivalent to @code{--set-variable variable=value} on the command line.
+This syntax must be used to set a @code{mysqld} variable.
+@end table
+
+The @code{client} group allows you to specify options that apply to all
+@strong{MySQL} clients (not @code{mysqld}). This is the perfect group to use
+to specify the password you use to connect to the server. (But make
+sure the option file is readable and writable only by yourself.)
+
+Note that for options and values, all leading and trailing blanks are
+automatically deleted. You may use the escape sequences @samp{\b},
+@samp{\t}, @samp{\n}, @samp{\r}, @samp{\\}, and @samp{\s} in your value string
+(@samp{\s} == blank).
+
+Here is a typical global option file:
+
+@example
+[client]
+port=3306
+socket=/tmp/mysql.sock
+
+[mysqld]
+port=3306
+socket=/tmp/mysql.sock
+set-variable = key_buffer_size=16M
+set-variable = max_allowed_packet=1M
+
+[mysqldump]
+quick
+@end example
+
+Here is typical user option file:
+
+@example
+[client]
+# The following password will be sent to all standard MySQL clients
+password=my_password
+
+[mysql]
+no-auto-rehash
+set-variable = connect_timeout=2
+
+[mysqlhotcopy]
+interactive-timeout
+
+@end example
+
+@tindex .my.cnf file
+If you have a source distribution, you will find sample configuration
+files named @file{my-xxxx.cnf} in the @file{support-files} directory.
+If you have a binary distribution, look in the @file{DIR/support-files}
+directory, where @code{DIR} is the pathname to the @strong{MySQL}
+installation directory (typically @file{/usr/local/mysql}). Currently
+there are sample configuration files for small, medium, large, and very
+large systems. You can copy @file{my-xxxx.cnf} to your home directory
+(rename the copy to @file{.my.cnf}) to experiment with this.
+
+All @strong{MySQL} clients that support option files support the
+following options:
+
+@multitable @columnfractions .40 .60
+@item --no-defaults @tab Don't read any option files.
+@item --print-defaults @tab Print the program name and all options that it will get.
+@item --defaults-file=full-path-to-default-file @tab Only use the given configuration file.
+@item --defaults-extra-file=full-path-to-default-file @tab Read this configuration file after the global configuration file but before the user configuration file.
+@end multitable
+
+Note that the above options must be first on the command line to work!
+@code{--print-defaults} may however be used directly after the
+@code{--defaults-xxx-file} commands.
+
+Note for developers: Option file handling is implemented simply by
+processing all matching options (that is, options in the appropriate group)
+before any command-line arguments. This works nicely for programs that use
+the last instance of an option that is specified multiple times. If you have
+an old program that handles multiply-specified options this way but doesn't
+read option files, you need add only two lines to give it that capability.
+Check the source code of any of the standard @strong{MySQL} clients to see
+how to do this.
+
+In shell scripts you can use the @file{my_print_defaults} command to parse the
+config files:
+
+@example
+
+shell> my_print_defaults client mysql
+--port=3306
+--socket=/tmp/mysql.sock
+--no-auto-rehash
+@end example
+
+The above output contains all options for the groups 'client' and 'mysql'.
+
+
+@node Installing many servers, Privilege system, Configuring MySQL, MySQL Database Administration
+@appendixsec Installing Many Servers on the Same Machine
+
+@cindex post-install, many servers
+@cindex Installing many servers
+@cindex Starting many servers
+
+In some cases you may want to have many different @code{mysqld} daemons
+(servers) running on the same machine. You may for example want to run
+a new version of @strong{MySQL} for testing together with an old version
+that is in production. Another case is when you want to give different
+users access to different @code{mysqld} servers that they manage themselves.
+
+One way to get a new server running is by starting it with a different
+socket and port as follows:
+
+@tindex MYSQL_UNIX_PORT environment variable
+@tindex MYSQL_TCP_PORT environment variable
+@tindex Environment variable, MYSQL_UNIX_PORT
+@tindex Environment variable, MYSQL_TCP_PORT
+@example
+shell> MYSQL_UNIX_PORT=/tmp/mysqld-new.sock
+shell> MYSQL_TCP_PORT=3307
+shell> export MYSQL_UNIX_PORT MYSQL_TCP_PORT
+shell> scripts/mysql_install_db
+shell> bin/safe_mysqld &
+@end example
+
+The environment variables appendix includes a list of other environment
+variables you can use to affect @code{mysqld}. @xref{Environment variables}.
+
+The above is the quick and dirty way that one commonly uses for testing.
+The nice thing with this is that all connections you do in the above shell
+will automatically be directed to the new running server!
+
+If you need to do this more permanently, you should create an option
+file for each server. @xref{Option files}. In your startup script that
+is executed at boot time (mysql.server?) you should specify for both
+servers:
+
+@code{safe_mysqld --default-file=path-to-option-file}
+
+At least the following options should be different per server:
+
+@table @code
+@item port=#
+@item socket=path
+@item pid-file=path
+@end table
+
+The following options should be different, if they are used:
+
+@table @code
+@item log=path
+@item log-bin=path
+@item log-update=path
+@item log-isam=path
+@item bdb-logdir=path
+@end table
+
+If you want more performance, you can also specify the following differently:
+
+@table @code
+@item tmpdir=path
+@item bdb-tmpdir=path
+@end table
+
+@xref{Command-line options}.
+
+If you are installing binary @strong{MySQL} versions (.tar files) and
+start them with @code{./bin/safe_mysqld} then in most cases the only
+option you need to add/change is the @code{socket} and @code{port}
+argument to @code{safe_mysqld}.
+
+
+@menu
+* Multiple servers::
+@end menu
+
+@node Multiple servers, , Installing many servers, Installing many servers
+@subsection Running Multiple MySQL Servers on the Same Machine
+
+@cindex multiple servers
+@cindex servers, multiple
+@cindex running, multiple servers
+
+There are circumstances when you might want to run multiple servers on the same
+machine. For example, you might want to test a new @strong{MySQL} release
+while leaving your existing production setup undisturbed. Or you might
+be an Internet service provider that wants to provide independent
+@strong{MySQL} installations for different customers.
+
+If you want to run multiple servers, the easiest way is to compile the servers
+with different TCP/IP ports and socket files so they are not
+both listening to the same TCP/IP port or socket file. @xref{mysqld_multi, ,
+@code{mysqld_multi}}.
+
+Assume an existing server is configured for the default port number and
+socket file. Then configure the new server with a @code{configure} command
+something like this:
+
+@example
+shell> ./configure --with-tcp-port=port_number \
+ --with-unix-socket-path=file_name \
+ --prefix=/usr/local/mysql-3.22.9
+@end example
+
+Here @code{port_number} and @code{file_name} should be different than the
+default port number and socket file pathname, and the @code{--prefix} value
+should specify an installation directory different than the one under which
+the existing @strong{MySQL} installation is located.
+
+You can check the socket used by any currently executing @strong{MySQL} server
+with this command:
+
+@example
+shell> mysqladmin -h hostname --port=port_number variables
+@end example
+
+Note that if you specify ``@code{localhost}'' as a hostname, @code{mysqladmin}
+will default to using Unix sockets instead of TCP/IP.
+
+If you have a @strong{MySQL} server running on the port you used, you will
+get a list of some of the most important configurable variables in
+@strong{MySQL}, including the socket name.
+
+You don't have to recompile a new @strong{MySQL} server just to start with
+a different port and socket. You can change the port and socket to be used
+by specifying them at run time as options to @code{safe_mysqld}:
+
+@example
+shell> /path/to/safe_mysqld --socket=file_name --port=port_number
+@end example
+
+@code{mysqld_multi} can also take @code{safe_mysqld} (or @code{mysqld})
+as an argument and pass the options from a configuration file to
+@code{safe_mysqld} and further to @code{mysqld}.
+
+If you run the new server on the same database directory as another
+server with logging enabled, you should also specify the name of the log
+files to @code{safe_mysqld} with @code{--log}, @code{--log-update}, or
+@code{--log-slow-queries}. Otherwise, both servers may be trying to
+write to the same log file.
+
+@strong{WARNING}: Normally you should never have two servers that update
+data in the same database! If your OS doesn't support fault-free system
+locking, this may lead to unpleasant surprises!
+
+If you want to use another database directory for the second server, you
+can use the @code{--datadir=path} option to @code{safe_mysqld}.
+
+@strong{NOTE} also that starting several @strong{MySQL} servers
+(@code{mysqlds}) in different machines and letting them access one data
+directory over @code{NFS} is generally a @strong{BAD IDEA}! The problem
+is that the @code{NFS} will become the bottleneck with the speed. It is
+not meant for such use. And last but not least, you would still have to
+come up with a solution how to make sure that two or more @code{mysqlds}
+are not interfering with each other. At the moment there is no platform
+that would 100% reliable do the file locking (@code{lockd} daemon
+usually) in every situation. Yet there would be one more possible risk
+with @code{NFS}; it would make the work even more complicated for
+@code{lockd} daemon to handle. So make it easy for your self and forget
+about the idea. The working solution is to have one computer with an
+operating system that efficiently handles threads and have several CPUs
+in it.
+
+When you want to connect to a @strong{MySQL} server that is running with
+a different port than the port that is compiled into your client, you
+can use one of the following methods:
+
+@itemize @bullet
+@item
+Start the client with @code{--host 'hostname' --port=port_number} to connect
+with TCP/IP, or @code{[--host localhost] --socket=file_name} to connect via
+a Unix socket.
+
+@item
+In your C or Perl programs, you can give the port or socket arguments
+when connecting to the @strong{MySQL} server.
+
+@item
+If your are using the Perl @code{DBD::mysql} module you can read the options
+from the @strong{MySQL} option files. @xref{Option files}.
+
+@example
+$dsn = "DBI:mysql:test;mysql_read_default_group=client;mysql_read_default_file=/usr/local/mysql/data/my.cnf"
+$dbh = DBI->connect($dsn, $user, $password);
+@end example
+
+@item
+@tindex MYSQL_UNIX_PORT environment variable
+@tindex MYSQL_TCP_PORT environment variable
+@tindex environment variable, MYSQL_UNIX_PORT
+@tindex environment variable, MYSQL_TCP_PORT
+Set the @code{MYSQL_UNIX_PORT} and @code{MYSQL_TCP_PORT} environment variables
+to point to the Unix socket and TCP/IP port before you start your clients.
+If you normally use a specific socket or port, you should place commands
+to set these environment variables in your @file{.login} file.
+@xref{Environment variables}.
+
+@item
+@tindex .my.cnf file
+Specify the default socket and TCP/IP port in the @file{.my.cnf} file in your
+home directory. @xref{Option files}.
+@end itemize
+
+
+@node Privilege system, User Account Management, Installing many servers, MySQL Database Administration
+@section General Security Issues and the MySQL Access Privilege System
@cindex system, security
@cindex access privileges
@@ -14293,7 +14963,6 @@ FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\'
@cindex security system
@cindex ACLs
-
@strong{MySQL} has an advanced but non-standard security/privilege
system. This section describes how it works.
@@ -14302,22 +14971,17 @@ system. This section describes how it works.
* Security:: How to make @strong{MySQL} secure against crackers
* Privileges options::
* What Privileges:: What the privilege system does
-* User names:: @strong{MySQL} user names and passwords
-* Connecting:: Connecting to the @strong{MySQL} server
-* Password security:: Keeping your password secure
-* Privileges provided:: Privileges provided by @strong{MySQL}
* Privileges:: How the privilege system works
+* Privileges provided:: Privileges provided by @strong{MySQL}
+* Connecting:: Connecting to the @strong{MySQL} server
* Connection access:: Access control, stage 1: Connection verification
* Request access:: Access control, stage 2: Request verification
-* Privilege changes:: When privilege changes take effect
-* Default privileges:: Setting up the initial @strong{MySQL} privileges
-* Adding users:: Adding new users to @strong{MySQL}
-* Passwords:: How to set up passwords
* Access denied:: Causes of @code{Access denied} errors
@end menu
+
@node General security, Security, Privilege system, Privilege system
-@section General Security
+@subsection General Security Guidelines
Anyone using @strong{MySQL} on a computer connected to the Internet
should read this section to avoid the most common security mistakes.
@@ -14501,8 +15165,10 @@ actually mean that it is encrypted. If you need high security, you should
consult with a security expert.
@end itemize
+
@node Security, Privileges options, General security, Privilege system
-@section How to Make MySQL Secure Against Crackers
+@subsection How to Make MySQL Secure Against Crackers
+
@cindex crackers, security against
@cindex security, against crackers
@@ -14620,7 +15286,7 @@ can do this by setting the @code{max_user_connections} variable in
@end itemize
@node Privileges options, What Privileges, Security, Privilege system
-@section Startup Options for @code{mysqld} Concerning Security
+@subsection Startup Options for @code{mysqld} Concerning Security
The following @code{mysqld} options affect networking security:
@@ -14662,8 +15328,10 @@ some kind of privilege.
@end table
-@node What Privileges, User names, Privileges options, Privilege system
-@section What the Privilege System Does
+
+@node What Privileges, Privileges, Privileges options, Privilege system
+@subsection What the Privilege System Does
+
@cindex system, privilege
@cindex privilege system
@cindex passwords, security
@@ -14677,243 +15345,214 @@ Additional functionality includes the ability to have an anonymous user and
to grant privileges for @strong{MySQL}-specific functions such as @code{LOAD
DATA INFILE} and administrative operations.
-@node User names, Connecting, What Privileges, Privilege system
-@section MySQL User Names and Passwords
-@cindex user names, and passwords
-@cindex passwords, for users
-There are several distinctions between the way user names and passwords are
-used by @strong{MySQL} and the way they are used by Unix or Windows:
+@node Privileges, Privileges provided, What Privileges, Privilege system
+@subsection How the Privilege System Works
-@itemize @bullet
-@item
-User names, as used by @strong{MySQL} for authentication purposes, have
-nothing to do with Unix user names (login names) or Windows user names. Most
-@strong{MySQL} clients by default try to log in using the current Unix user
-name as the @strong{MySQL} user name, but that is for convenience only.
-Client programs allow a different name to be specified with the @code{-u} or
-@code{--user} options. This means that you can't make a database secure in
-any way unless all @strong{MySQL} user names have passwords. Anyone may
-attempt to connect to the server using any name, and they will succeed if
-they specify any name that doesn't have a password.
+@cindex privilege system, described
-@item
-@strong{MySQL} user names can be up to 16 characters long; Unix user names
-typically are limited to 8 characters.
+The @strong{MySQL} privilege system ensures that all users may do exactly the
+things that they are supposed to be allowed to do. When you connect to a
+@strong{MySQL} server, your identity is determined by @strong{the host from
+which you connect} and @strong{the user name you specify}. The system grants
+privileges according to your identity and @strong{what you want to do}.
+@strong{MySQL} considers both your hostname and user name in identifying you
+because there is little reason to assume that a given user name belongs to
+the same person everywhere on the Internet. For example, the user
+@code{bill} who connects from @code{whitehouse.gov} need not be the same
+person as the user @code{bill} who connects from @code{microsoft.com}.
+@strong{MySQL} handles this by allowing you to distinguish users on different
+hosts that happen to have the same name: you can grant @code{bill} one set
+of privileges for connections from @code{whitehouse.gov}, and a different set
+of privileges for connections from @code{microsoft.com}.
+
+@strong{MySQL} access control involves two stages:
+
+@itemize @bullet
@item
-@strong{MySQL} passwords have nothing to do with Unix passwords. There is no
-necessary connection between the password you use to log in to a Unix machine
-and the password you use to access a database on that machine.
+Stage 1: The server checks whether or not you are even allowed to connect.
@item
-@strong{MySQL} encrypts passwords using a different algorithm than the
-one used during the Unix login process. See the descriptions of the
-@code{PASSWORD()} and @code{ENCRYPT()} functions in @ref{Miscellaneous
-functions}. Note that even if the password is stored 'scrambled', and
-knowing your 'scrambled' password is enough to be able to connect to
-the @strong{MySQL} server!
+Stage 2: Assuming you can connect, the server checks each request you issue
+to see whether or not you have sufficient privileges to perform it. For
+example, if you try to select rows from a table in a database or drop a table
+from the database, the server makes sure you have the @strong{select}
+privilege for the table or the @strong{drop} privilege for the database.
@end itemize
-@strong{MySQL} users and they privileges are normally created with the
-@code{GRANT} command. @xref{GRANT}.
-
-When you login to a @strong{MySQL} server with a command line client you
-should specify the password with @code{--password=your-password}.
-@xref{Connecting}.
-
-@example
-mysql --user=monty --password=guess database_name
-@end example
-
-If you want the client to prompt for a password, you should use
-@code{--password} without any argument
-
-@example
-mysql --user=monty --password database_name
-@end example
-
-or the short form:
+The server uses the @code{user}, @code{db}, and @code{host} tables in the
+@code{mysql} database at both stages of access control. The fields in these
+grant tables are shown below:
-@example
-mysql -u monty -p database_name
-@end example
+@multitable @columnfractions .2 .25 .25 .25
+@item @strong{Table name} @tab @code{user} @tab @code{db} @tab @code{host}
-Note that in the last example the password is @strong{NOT} 'database_name'.
+@item @strong{Scope fields} @tab @code{Host} @tab @code{Host} @tab @code{Host}
+@item @tab @code{User} @tab @code{Db} @tab @code{Db}
+@item @tab @code{Password} @tab @code{User} @tab
-If you want to use the @code{-p} option to supply a password you should do like this:
+@item @strong{Privilege fields} @tab @code{Select_priv} @tab @code{Select_priv} @tab @code{Select_priv}
+@item @tab @code{Insert_priv} @tab @code{Insert_priv} @tab @code{Insert_priv}
+@item @tab @code{Update_priv} @tab @code{Update_priv} @tab @code{Update_priv}
+@item @tab @code{Delete_priv} @tab @code{Delete_priv} @tab @code{Delete_priv}
+@item @tab @code{Index_priv} @tab @code{Index_priv} @tab @code{Index_priv}
+@item @tab @code{Alter_priv} @tab @code{Alter_priv} @tab @code{Alter_priv}
+@item @tab @code{Create_priv} @tab @code{Create_priv} @tab @code{Create_priv}
+@item @tab @code{Drop_priv} @tab @code{Drop_priv} @tab @code{Drop_priv}
+@item @tab @code{Grant_priv} @tab @code{Grant_priv} @tab @code{Grant_priv}
+@item @tab @code{References_priv} @tab @tab
+@item @tab @code{Reload_priv} @tab @tab
+@item @tab @code{Shutdown_priv} @tab @tab
+@item @tab @code{Process_priv} @tab @tab
+@item @tab @code{File_priv} @tab @tab
+@end multitable
-@example
-mysql -u monty -pguess database_name
-@end example
+For the second stage of access control (request verification), the server
+may, if the request involves tables, additionally consult the
+@code{tables_priv} and @code{columns_priv} tables. The fields in these
+tables are shown below:
-On some system the library call that @strong{MySQL} uses to prompt for a
-password will automatically cut the password to 8 characters. Internally
-@strong{MySQL} doesn't have any limit for the length of the password.
+@multitable @columnfractions .2 .25 .25
+@item @strong{Table name} @tab @code{tables_priv} @tab @code{columns_priv}
-@node Connecting, Password security, User names, Privilege system
-@section Connecting to the MySQL Server
-@cindex connecting, to the server
-@cindex default hostname
-@cindex hostname, default
-@cindex server, connecting
+@item @strong{Scope fields} @tab @code{Host} @tab @code{Host}
+@item @tab @code{Db} @tab @code{Db}
+@item @tab @code{User} @tab @code{User}
+@item @tab @code{Table_name} @tab @code{Table_name}
+@item @tab @tab @code{Column_name}
-@strong{MySQL} client programs generally require that you specify connection
-parameters when you want to access a @strong{MySQL} server: the host you want
-to connect to, your user name, and your password. For example, the
-@code{mysql} client can be started like this (optional arguments are enclosed
-between @samp{[} and @samp{]}):
+@item @strong{Privilege fields} @tab @code{Table_priv} @tab @code{Column_priv}
+@item @tab @code{Column_priv} @tab
-@example
-shell> mysql [-h host_name] [-u user_name] [-pyour_pass]
-@end example
+@item @strong{Other fields} @tab @code{Timestamp} @tab @code{Timestamp}
+@item @tab @code{Grantor} @tab
+@end multitable
-Alternate forms of the @code{-h}, @code{-u}, and @code{-p} options are
-@code{--host=host_name}, @code{--user=user_name}, and
-@code{--password=your_pass}. Note that there is @emph{no space} between
-@code{-p} or @code{--password=} and the password following it.
+Each grant table contains scope fields and privilege fields.
-@strong{NOTE:} Specifying a password on the command line is not secure!
-Any user on your system may then find out your password by typing a command
-like: @code{ps auxww}. @xref{Option files}.
+Scope fields determine the scope of each entry in the tables, that is, the
+context in which the entry applies. For example, a @code{user} table entry
+with @code{Host} and @code{User} values of @code{'thomas.loc.gov'} and
+@code{'bob'} would be used for authenticating connections made to the server
+by @code{bob} from the host @code{thomas.loc.gov}. Similarly, a @code{db}
+table entry with @code{Host}, @code{User}, and @code{Db} fields of
+@code{'thomas.loc.gov'}, @code{'bob'} and @code{'reports'} would be used when
+@code{bob} connects from the host @code{thomas.loc.gov} to access the
+@code{reports} database. The @code{tables_priv} and @code{columns_priv}
+tables contain scope fields indicating tables or table/column combinations
+to which each entry applies.
-@code{mysql} uses default values for connection parameters that are missing
-from the command line:
+@cindex case sensitivity, in access checking
+For access-checking purposes, comparisons of @code{Host} values are
+case insensitive. @code{User}, @code{Password}, @code{Db}, and
+@code{Table_name} values are case sensitive.
+@code{Column_name} values are case insensitive in @strong{MySQL} Version
+3.22.12 or later.
-@itemize @bullet
-@item
-The default hostname is @code{localhost}.
+Privilege fields indicate the privileges granted by a table entry, that is,
+what operations can be performed. The server combines the information in the
+various grant tables to form a complete description of a user's privileges.
+The rules used to do this are described in @ref{Request access}.
-@item
-The default user name is your Unix login name.
+Scope fields are strings, declared as shown below; the default value for
+each is the empty string:
-@item
-No password is supplied if @code{-p} is missing.
-@end itemize
+@multitable @columnfractions .15 .15 .7
+@item @strong{Field name} @tab @strong{Type}
+@item @code{Host} @tab @code{CHAR(60)}
+@item @code{User} @tab @code{CHAR(16)}
+@item @code{Password} @tab @code{CHAR(16)}
+@item @code{Db} @tab @code{CHAR(64)} @tab (@code{CHAR(60)} for the
+@code{tables_priv} and @code{columns_priv} tables)
+@item @code{Table_name} @tab @code{CHAR(60)}
+@item @code{Column_name} @tab @code{CHAR(60)}
+@end multitable
-Thus, for a Unix user @code{joe}, the following commands are equivalent:
+In the @code{user}, @code{db} and @code{host} tables,
+all privilege fields are declared as @code{ENUM('N','Y')} --- each can have a
+value of @code{'N'} or @code{'Y'}, and the default value is @code{'N'}.
-@example
-shell> mysql -h localhost -u joe
-shell> mysql -h localhost
-shell> mysql -u joe
-shell> mysql
-@end example
+In the @code{tables_priv} and @code{columns_priv} tables, the privilege
+fields are declared as @code{SET} fields:
-Other @strong{MySQL} clients behave similarly.
+@multitable @columnfractions .2 .2 .6
+@item @strong{Table name} @tab @strong{Field name} @tab @strong{Possible set elements}
+@item @code{tables_priv} @tab @code{Table_priv} @tab @code{'Select', 'Insert',
+'Update', 'Delete', 'Create', 'Drop', 'Grant', 'References', 'Index', 'Alter'}
+@item @code{tables_priv} @tab @code{Column_priv} @tab @code{'Select', 'Insert',
+'Update', 'References'}
+@item @code{columns_priv} @tab @code{Column_priv} @tab @code{'Select', 'Insert',
+'Update', 'References'}
+@end multitable
-On Unix systems, you can specify different default values to be used when you
-make a connection, so that you need not enter them on the command line each
-time you invoke a client program. This can be done in a couple of ways:
+Briefly, the server uses the grant tables like this:
@itemize @bullet
@item
-@tindex .my.cnf file
-You can specify connection parameters in the @code{[client]} section of the
-@file{.my.cnf} configuration file in your home directory. The relevant
-section of the file might look like this:
-
-@example
-[client]
-host=host_name
-user=user_name
-password=your_pass
-@end example
-
-@xref{Option files}.
+The @code{user} table scope fields determine whether to allow or reject
+incoming connections. For allowed connections, any privileges granted in
+the @code{user} table indicate the user's global (superuser) privileges.
+These privileges apply to @strong{all} databases on the server.
@item
-@tindex MYSQL_HOST environment variable
-@tindex Environment variable, MYSQL_HOST
-@tindex MYSQL_PWD environment variable
-@tindex Environment variable, MYSQL_PWD
-@tindex USER environment variable
-@tindex Environment variable, USER
-You can specify connection parameters using environment variables. The
-host can be specified for @code{mysql} using @code{MYSQL_HOST}. The
-@strong{MySQL} user name can be specified using @code{USER} (this is for
-Windows only). The password can be specified using @code{MYSQL_PWD}
-(but this is insecure; see the next section). @xref{Environment variables}.
-@end itemize
-
-@node Password security, Privileges provided, Connecting, Privilege system
-@section Keeping Your Password Secure
-
-It is inadvisable to specify your password in a way that exposes it to
-discovery by other users. The methods you can use to specify your password
-when you run client programs are listed below, along with an assessment of
-the risks of each method:
+The @code{db} and @code{host} tables are used together:
-@itemize @bullet
+@itemize @minus
@item
-Never give a normal user access to the @code{mysql.user} table. Knowing
-the encrypted password for a user makes it possible to login as this
-user. The passwords are only scrambled so that one shouldn't be able to
-see the real password you used (if you happen to use a similar password
-with your other applications).
+The @code{db} table scope fields determine which users can access which
+databases from which hosts. The privilege fields determine which operations
+are allowed.
@item
-Use a @code{-pyour_pass} or @code{--password=your_pass} option on the command
-line. This is convenient but insecure, because your password becomes visible
-to system status programs (such as @code{ps}) that may be invoked by other
-users to display command lines. (@strong{MySQL} clients typically overwrite
-the command-line argument with zeroes during their initialization sequence,
-but there is still a brief interval during which the value is visible.)
+The @code{host} table is used as an extension of the @code{db} table when you
+want a given @code{db} table entry to apply to several hosts. For example,
+if you want a user to be able to use a database from several hosts in
+your network, leave the @code{Host} value empty in the user's @code{db} table
+entry, then populate the @code{host} table with an entry for each of those
+hosts. This mechanism is described more detail in @ref{Request access}.
+@end itemize
@item
-Use a @code{-p} or @code{--password} option (with no @code{your_pass} value
-specified). In this case, the client program solicits the password from
-the terminal:
-@findex -p option
-@findex -password option
-
-@example
-shell> mysql -u user_name -p
-Enter password: ********
-@end example
+The @code{tables_priv} and @code{columns_priv} tables are similar to
+the @code{db} table, but are more fine-grained: they apply at the
+table and column levels rather than at the database level.
+@end itemize
-The @samp{*} characters represent your password.
+Note that administrative privileges (@strong{reload}, @strong{shutdown},
+etc.) are specified only in the @code{user} table. This is because
+administrative operations are operations on the server itself and are not
+database-specific, so there is no reason to list such privileges in the
+other grant tables. In fact, only the @code{user} table need
+be consulted to determine whether or not you can perform an administrative
+operation.
-It is more secure to enter your password this way than to specify it on the
-command line because it is not visible to other users. However, this method
-of entering a password is suitable only for programs that you run
-interactively. If you want to invoke a client from a script that runs
-non-interactively, there is no opportunity to enter the password from the
-terminal. On some systems, you may even find that the first line of your
-script is read and interpreted (incorrectly) as your password!
+The @strong{file} privilege is specified only in the @code{user} table, too.
+It is not an administrative privilege as such, but your ability to read or
+write files on the server host is independent of the database you are
+accessing.
-@item
-@tindex .my.cnf file
-Store your password in a configuration file. For example, you can list your
-password in the @code{[client]} section of the @file{.my.cnf} file in your
-home directory:
+The @code{mysqld} server reads the contents of the grant tables once, when it
+starts up. Changes to the grant tables take effect as indicated in
+@ref{Privilege changes}.
-@example
-[client]
-password=your_pass
-@end example
+When you modify the contents of the grant tables, it is a good idea to make
+sure that your changes set up privileges the way you want. For help in
+diagnosing problems, see @ref{Access denied}. For advice on security issues,
+@pxref{Security}.
-If you store your password in @file{.my.cnf}, the file should not be group or
-world readable or writable. Make sure the file's access mode is @code{400}
-or @code{600}.
+A useful
+diagnostic tool is the @code{mysqlaccess} script, which Yves Carlier has
+provided for the @strong{MySQL} distribution. Invoke @code{mysqlaccess} with
+the @code{--help} option to find out how it works.
+Note that @code{mysqlaccess} checks access using only the @code{user},
+@code{db} and @code{host} tables. It does not check table- or column-level
+privileges.
-@xref{Option files}.
-@item
-You can store your password in the @code{MYSQL_PWD} environment variable, but
-this method must be considered extremely insecure and should not be used.
-Some versions of @code{ps} include an option to display the environment of
-running processes; your password will be in plain sight for all to see if
-you set @code{MYSQL_PWD}. Even on systems without such a version of
-@code{ps}, it is unwise to assume there is no other method to observe process
-environments. @xref{Environment variables}.
-@end itemize
-All in all, the safest methods are to have the client program prompt for the
-password or to specify the password in a properly protected @file{.my.cnf}
-file.
+@node Privileges provided, Connecting, Privileges, Privilege system
+@subsection Privileges Provided by MySQL
-@node Privileges provided, Privileges, Password security, Privilege system
-@section Privileges Provided by MySQL
@cindex privilege information, location
Information about user privileges is stored in the @code{user}, @code{db},
@@ -15060,210 +15699,97 @@ You cannot specify that a user has privileges to create or drop tables
in a database but not to create or drop the database itself.
@end itemize
-@node Privileges, Connection access, Privileges provided, Privilege system
-@section How the Privilege System Works
-@cindex privilege system, described
-
-The @strong{MySQL} privilege system ensures that all users may do exactly the
-things that they are supposed to be allowed to do. When you connect to a
-@strong{MySQL} server, your identity is determined by @strong{the host from
-which you connect} and @strong{the user name you specify}. The system grants
-privileges according to your identity and @strong{what you want to do}.
-
-@strong{MySQL} considers both your hostname and user name in identifying you
-because there is little reason to assume that a given user name belongs to
-the same person everywhere on the Internet. For example, the user
-@code{bill} who connects from @code{whitehouse.gov} need not be the same
-person as the user @code{bill} who connects from @code{microsoft.com}.
-@strong{MySQL} handles this by allowing you to distinguish users on different
-hosts that happen to have the same name: you can grant @code{bill} one set
-of privileges for connections from @code{whitehouse.gov}, and a different set
-of privileges for connections from @code{microsoft.com}.
-
-@strong{MySQL} access control involves two stages:
-
-@itemize @bullet
-@item
-Stage 1: The server checks whether or not you are even allowed to connect.
-
-@item
-Stage 2: Assuming you can connect, the server checks each request you issue
-to see whether or not you have sufficient privileges to perform it. For
-example, if you try to select rows from a table in a database or drop a table
-from the database, the server makes sure you have the @strong{select}
-privilege for the table or the @strong{drop} privilege for the database.
-@end itemize
-
-The server uses the @code{user}, @code{db}, and @code{host} tables in the
-@code{mysql} database at both stages of access control. The fields in these
-grant tables are shown below:
-@multitable @columnfractions .2 .25 .25 .25
-@item @strong{Table name} @tab @code{user} @tab @code{db} @tab @code{host}
+@node Connecting, Connection access, Privileges provided, Privilege system
+@subsection Connecting to the MySQL Server
-@item @strong{Scope fields} @tab @code{Host} @tab @code{Host} @tab @code{Host}
-@item @tab @code{User} @tab @code{Db} @tab @code{Db}
-@item @tab @code{Password} @tab @code{User} @tab
-
-@item @strong{Privilege fields} @tab @code{Select_priv} @tab @code{Select_priv} @tab @code{Select_priv}
-@item @tab @code{Insert_priv} @tab @code{Insert_priv} @tab @code{Insert_priv}
-@item @tab @code{Update_priv} @tab @code{Update_priv} @tab @code{Update_priv}
-@item @tab @code{Delete_priv} @tab @code{Delete_priv} @tab @code{Delete_priv}
-@item @tab @code{Index_priv} @tab @code{Index_priv} @tab @code{Index_priv}
-@item @tab @code{Alter_priv} @tab @code{Alter_priv} @tab @code{Alter_priv}
-@item @tab @code{Create_priv} @tab @code{Create_priv} @tab @code{Create_priv}
-@item @tab @code{Drop_priv} @tab @code{Drop_priv} @tab @code{Drop_priv}
-@item @tab @code{Grant_priv} @tab @code{Grant_priv} @tab @code{Grant_priv}
-@item @tab @code{References_priv} @tab @tab
-@item @tab @code{Reload_priv} @tab @tab
-@item @tab @code{Shutdown_priv} @tab @tab
-@item @tab @code{Process_priv} @tab @tab
-@item @tab @code{File_priv} @tab @tab
-@end multitable
-
-For the second stage of access control (request verification), the server
-may, if the request involves tables, additionally consult the
-@code{tables_priv} and @code{columns_priv} tables. The fields in these
-tables are shown below:
-
-@multitable @columnfractions .2 .25 .25
-@item @strong{Table name} @tab @code{tables_priv} @tab @code{columns_priv}
-
-@item @strong{Scope fields} @tab @code{Host} @tab @code{Host}
-@item @tab @code{Db} @tab @code{Db}
-@item @tab @code{User} @tab @code{User}
-@item @tab @code{Table_name} @tab @code{Table_name}
-@item @tab @tab @code{Column_name}
+@cindex connecting, to the server
+@cindex default hostname
+@cindex hostname, default
+@cindex server, connecting
-@item @strong{Privilege fields} @tab @code{Table_priv} @tab @code{Column_priv}
-@item @tab @code{Column_priv} @tab
+@strong{MySQL} client programs generally require that you specify connection
+parameters when you want to access a @strong{MySQL} server: the host you want
+to connect to, your user name, and your password. For example, the
+@code{mysql} client can be started like this (optional arguments are enclosed
+between @samp{[} and @samp{]}):
-@item @strong{Other fields} @tab @code{Timestamp} @tab @code{Timestamp}
-@item @tab @code{Grantor} @tab
-@end multitable
+@example
+shell> mysql [-h host_name] [-u user_name] [-pyour_pass]
+@end example
-Each grant table contains scope fields and privilege fields.
+Alternate forms of the @code{-h}, @code{-u}, and @code{-p} options are
+@code{--host=host_name}, @code{--user=user_name}, and
+@code{--password=your_pass}. Note that there is @emph{no space} between
+@code{-p} or @code{--password=} and the password following it.
-Scope fields determine the scope of each entry in the tables, that is, the
-context in which the entry applies. For example, a @code{user} table entry
-with @code{Host} and @code{User} values of @code{'thomas.loc.gov'} and
-@code{'bob'} would be used for authenticating connections made to the server
-by @code{bob} from the host @code{thomas.loc.gov}. Similarly, a @code{db}
-table entry with @code{Host}, @code{User}, and @code{Db} fields of
-@code{'thomas.loc.gov'}, @code{'bob'} and @code{'reports'} would be used when
-@code{bob} connects from the host @code{thomas.loc.gov} to access the
-@code{reports} database. The @code{tables_priv} and @code{columns_priv}
-tables contain scope fields indicating tables or table/column combinations
-to which each entry applies.
+@strong{NOTE:} Specifying a password on the command line is not secure!
+Any user on your system may then find out your password by typing a command
+like: @code{ps auxww}. @xref{Option files}.
-@cindex case sensitivity, in access checking
-For access-checking purposes, comparisons of @code{Host} values are
-case insensitive. @code{User}, @code{Password}, @code{Db}, and
-@code{Table_name} values are case sensitive.
-@code{Column_name} values are case insensitive in @strong{MySQL} Version
-3.22.12 or later.
+@code{mysql} uses default values for connection parameters that are missing
+from the command line:
-Privilege fields indicate the privileges granted by a table entry, that is,
-what operations can be performed. The server combines the information in the
-various grant tables to form a complete description of a user's privileges.
-The rules used to do this are described in @ref{Request access}.
+@itemize @bullet
+@item
+The default hostname is @code{localhost}.
-Scope fields are strings, declared as shown below; the default value for
-each is the empty string:
+@item
+The default user name is your Unix login name.
-@multitable @columnfractions .15 .15 .7
-@item @strong{Field name} @tab @strong{Type}
-@item @code{Host} @tab @code{CHAR(60)}
-@item @code{User} @tab @code{CHAR(16)}
-@item @code{Password} @tab @code{CHAR(16)}
-@item @code{Db} @tab @code{CHAR(64)} @tab (@code{CHAR(60)} for the
-@code{tables_priv} and @code{columns_priv} tables)
-@item @code{Table_name} @tab @code{CHAR(60)}
-@item @code{Column_name} @tab @code{CHAR(60)}
-@end multitable
+@item
+No password is supplied if @code{-p} is missing.
+@end itemize
-In the @code{user}, @code{db} and @code{host} tables,
-all privilege fields are declared as @code{ENUM('N','Y')} --- each can have a
-value of @code{'N'} or @code{'Y'}, and the default value is @code{'N'}.
+Thus, for a Unix user @code{joe}, the following commands are equivalent:
-In the @code{tables_priv} and @code{columns_priv} tables, the privilege
-fields are declared as @code{SET} fields:
+@example
+shell> mysql -h localhost -u joe
+shell> mysql -h localhost
+shell> mysql -u joe
+shell> mysql
+@end example
-@multitable @columnfractions .2 .2 .6
-@item @strong{Table name} @tab @strong{Field name} @tab @strong{Possible set elements}
-@item @code{tables_priv} @tab @code{Table_priv} @tab @code{'Select', 'Insert',
-'Update', 'Delete', 'Create', 'Drop', 'Grant', 'References', 'Index', 'Alter'}
-@item @code{tables_priv} @tab @code{Column_priv} @tab @code{'Select', 'Insert',
-'Update', 'References'}
-@item @code{columns_priv} @tab @code{Column_priv} @tab @code{'Select', 'Insert',
-'Update', 'References'}
-@end multitable
+Other @strong{MySQL} clients behave similarly.
-Briefly, the server uses the grant tables like this:
+On Unix systems, you can specify different default values to be used when you
+make a connection, so that you need not enter them on the command line each
+time you invoke a client program. This can be done in a couple of ways:
@itemize @bullet
@item
-The @code{user} table scope fields determine whether to allow or reject
-incoming connections. For allowed connections, any privileges granted in
-the @code{user} table indicate the user's global (superuser) privileges.
-These privileges apply to @strong{all} databases on the server.
-
-@item
-The @code{db} and @code{host} tables are used together:
+@tindex .my.cnf file
+You can specify connection parameters in the @code{[client]} section of the
+@file{.my.cnf} configuration file in your home directory. The relevant
+section of the file might look like this:
-@itemize @minus
-@item
-The @code{db} table scope fields determine which users can access which
-databases from which hosts. The privilege fields determine which operations
-are allowed.
+@example
+[client]
+host=host_name
+user=user_name
+password=your_pass
+@end example
-@item
-The @code{host} table is used as an extension of the @code{db} table when you
-want a given @code{db} table entry to apply to several hosts. For example,
-if you want a user to be able to use a database from several hosts in
-your network, leave the @code{Host} value empty in the user's @code{db} table
-entry, then populate the @code{host} table with an entry for each of those
-hosts. This mechanism is described more detail in @ref{Request access}.
-@end itemize
+@xref{Option files}.
@item
-The @code{tables_priv} and @code{columns_priv} tables are similar to
-the @code{db} table, but are more fine-grained: they apply at the
-table and column levels rather than at the database level.
+@tindex MYSQL_HOST environment variable
+@tindex Environment variable, MYSQL_HOST
+@tindex MYSQL_PWD environment variable
+@tindex Environment variable, MYSQL_PWD
+@tindex USER environment variable
+@tindex Environment variable, USER
+You can specify connection parameters using environment variables. The
+host can be specified for @code{mysql} using @code{MYSQL_HOST}. The
+@strong{MySQL} user name can be specified using @code{USER} (this is for
+Windows only). The password can be specified using @code{MYSQL_PWD}
+(but this is insecure; see the next section). @xref{Environment variables}.
@end itemize
-Note that administrative privileges (@strong{reload}, @strong{shutdown},
-etc.) are specified only in the @code{user} table. This is because
-administrative operations are operations on the server itself and are not
-database-specific, so there is no reason to list such privileges in the
-other grant tables. In fact, only the @code{user} table need
-be consulted to determine whether or not you can perform an administrative
-operation.
-
-The @strong{file} privilege is specified only in the @code{user} table, too.
-It is not an administrative privilege as such, but your ability to read or
-write files on the server host is independent of the database you are
-accessing.
-The @code{mysqld} server reads the contents of the grant tables once, when it
-starts up. Changes to the grant tables take effect as indicated in
-@ref{Privilege changes}.
+@node Connection access, Request access, Connecting, Privilege system
+@subsection Access Control, Stage 1: Connection Verification
-When you modify the contents of the grant tables, it is a good idea to make
-sure that your changes set up privileges the way you want. For help in
-diagnosing problems, see @ref{Access denied}. For advice on security issues,
-@pxref{Security}.
-
-A useful
-diagnostic tool is the @code{mysqlaccess} script, which Yves Carlier has
-provided for the @strong{MySQL} distribution. Invoke @code{mysqlaccess} with
-the @code{--help} option to find out how it works.
-Note that @code{mysqlaccess} checks access using only the @code{user},
-@code{db} and @code{host} tables. It does not check table- or column-level
-privileges.
-
-@node Connection access, Request access, Privileges, Privilege system
-@section Access Control, Stage 1: Connection Verification
@cindex access control
@cindex control access
@cindex connecting, verification
@@ -15468,8 +15994,9 @@ as the @code{User} field value, but by the entry with no user name!
If you have problems connecting to the server, print out the @code{user}
table and sort it by hand to see where the first match is being made.
-@node Request access, Privilege changes, Connection access, Privilege system
-@section Access Control, Stage 2: Request Verification
+
+@node Request access, Access denied, Connection access, Privilege system
+@subsection Access Control, Stage 2: Request Verification
Once you establish a connection, the server enters Stage 2. For each request
that comes in on the connection, the server checks whether you have
@@ -15667,8 +16194,657 @@ Naturally, you should always test your entries in the grant tables (for
example, using @code{mysqlaccess}) to make sure your access privileges are
actually set up the way you think they are.
-@node Privilege changes, Default privileges, Request access, Privilege system
-@section When Privilege Changes Take Effect
+
+@node Access denied, , Request access, Privilege system
+@subsection Causes of @code{Access denied} Errors
+
+If you encounter @code{Access denied} errors when you try to connect to the
+@strong{MySQL} server, the list below indicates some courses of
+action you can take to correct the problem:
+
+@itemize @bullet
+@item
+After installing @strong{MySQL}, did you run the @code{mysql_install_db}
+script to set up the initial grant table contents? If not, do so.
+@xref{Default privileges}. Test the initial privileges by executing
+this command:
+
+@example
+shell> mysql -u root test
+@end example
+
+The server should let you connect without error. You should also make sure
+you have a file @file{user.MYD} in the @strong{MySQL} database directory.
+Ordinarily, this is @file{PATH/var/mysql/user.MYD}, where @code{PATH} is the
+pathname to the @strong{MySQL} installation root.
+
+@item
+After a fresh installation, you should connect to the server and set up
+your users and their access permissions:
+
+@example
+shell> mysql -u root mysql
+@end example
+
+The server should let you connect because the @strong{MySQL} @code{root} user
+has no password initially. That is also a security risk, so setting the
+@code{root} password is something you should do while you're setting up
+your other @strong{MySQL} users.
+
+If you try to connect as @code{root} and get this error:
+
+@example
+Access denied for user: '@@unknown' to database mysql
+@end example
+
+this means that you don't have an entry in the @code{user} table with a
+@code{User} column value of @code{'root'} and that @code{mysqld} cannot
+resolve the hostname for your client. In this case, you must restart the
+server with the @code{--skip-grant-tables} option and edit your
+@file{/etc/hosts} or @file{\windows\hosts} file to add an entry for your
+host.
+
+@item
+If you get an error like the following:
+
+@example
+shell> mysqladmin -u root -pxxxx ver
+Access denied for user: 'root@@localhost' (Using password: YES)
+@end example
+
+It means that you are using a wrong password. @xref{Passwords}.
+
+If you have forgot the root password, you can restart @code{mysqld} with
+@code{--skip-grant-tables} to change the password. You can find more
+about this option later on in this manual section.
+
+If you get the above error even if you haven't specified a password,
+this means that you a wrong password in some @code{my.ini}
+file. @xref{Option files}. You can avoid using option files with the @code{--no-defaults} option, as follows:
+
+@example
+shell> mysqladmin --no-defaults -u root ver
+@end example
+
+@item
+@cindex @code{mysql_fix_privilege_tables}
+If you updated an existing @strong{MySQL} installation from a version earlier
+than Version 3.22.11 to Version 3.22.11 or later, did you run the
+@code{mysql_fix_privilege_tables} script? If not, do so. The structure of
+the grant tables changed with @strong{MySQL} Version 3.22.11 when the
+@code{GRANT} statement became functional.
+
+@item
+If your privileges seem to have changed in the middle of a session, it may be
+that a superuser has changed them. Reloading the grant tables affects new
+client connections, but it also affects existing connections as indicated in
+@ref{Privilege changes}.
+
+@item
+If you can't get your password to work, remember that you must use
+the @code{PASSWORD()} function if you set the password with the
+@code{INSERT}, @code{UPDATE}, or @code{SET PASSWORD} statements. The
+@code{PASSWORD()} function is unnecessary if you specify the password using
+the @code{GRANT ... INDENTIFIED BY} statement or the @code{mysqladmin
+password} command.
+@xref{Passwords}.
+
+@item
+@code{localhost} is a synonym for your local hostname, and is also the
+default host to which clients try to connect if you specify no host
+explicitly. However, connections to @code{localhost} do not work if you are
+running on a system that uses MIT-pthreads (@code{localhost} connections are
+made using Unix sockets, which are not supported by MIT-pthreads). To avoid
+this problem on such systems, you should use the @code{--host} option to name
+the server host explicitly. This will make a TCP/IP connection to the
+@code{mysqld} server. In this case, you must have your real hostname in
+@code{user} table entries on the server host. (This is true even if you are
+running a client program on the same host as the server.)
+
+@item
+If you get an @code{Access denied} error when trying to connect to the
+database with @code{mysql -u user_name db_name}, you may have a problem
+with the @code{user} table. Check this by executing @code{mysql -u root
+mysql} and issuing this SQL statement:
+
+@example
+mysql> SELECT * FROM user;
+@end example
+
+The result should include an entry with the @code{Host} and @code{User}
+columns matching your computer's hostname and your @strong{MySQL} user name.
+
+@item
+The @code{Access denied} error message will tell you who you are trying
+to log in as, the host from which you are trying to connect, and whether
+or not you were using a password. Normally, you should have one entry in
+the @code{user} table that exactly matches the hostname and user name
+that were given in the error message. For example if you get an error
+message that contains @code{Using password: NO}, this means that you
+tried to login without an password.
+
+@item
+If you get the following error when you try to connect from a different host
+than the one on which the @strong{MySQL} server is running, then there is no
+row in the @code{user} table that matches that host:
+
+@example
+Host ... is not allowed to connect to this MySQL server
+@end example
+
+You can fix this by using the command-line tool @code{mysql} (on the
+server host!) to add a row to the @code{user}, @code{db}, or @code{host}
+table for the user/hostname combination from which you are trying to
+connect and then execute @code{mysqladmin flush-privileges}. If you are
+not running @strong{MySQL} Version 3.22 and you don't know the IP number or
+hostname of the machine from which you are connecting, you should put an
+entry with @code{'%'} as the @code{Host} column value in the @code{user}
+table and restart @code{mysqld} with the @code{--log} option on the
+server machine. After trying to connect from the client machine, the
+information in the @strong{MySQL} log will indicate how you really did
+connect. (Then replace the @code{'%'} in the @code{user} table entry
+with the actual hostname that shows up in the log. Otherwise, you'll
+have a system that is insecure.)
+
+Another reason for this error on Linux is that you are using a binary
+@strong{MySQL} version that is compiled with a different glibc version
+than the one you are using. In this case you should either upgrade your
+OS/glibc or download the source @strong{MySQL} version and compile this
+yourself. A source RPM is normally trivial to compile and install, so
+this isn't a big problem.
+
+@item
+If you get an error message where the hostname is not shown or where the
+hostname is an IP, even if you try to connect with a hostname:
+
+@example
+shell> mysqladmin -u root -pxxxx -h some-hostname ver
+Access denied for user: 'root@' (Using password: YES)
+@end example
+
+This means that @strong{MySQL} got some error when trying to resolve the
+IP to a hostname. In this case you can execute @code{mysqladmin
+flush-hosts} to reset the internal DNS cache. @xref{DNS}.
+
+Some permanent solutions are:
+
+@itemize @minus
+@item
+Try to find out what is wrong with your DNS server and fix this.
+
+@item
+Specify IPs instead of hostnames in the @strong{MySQL} privilege tables.
+
+@item
+Start @code{mysqld} with @code{--skip-name-resolve}.
+
+@item
+Start @code{mysqld} with @code{--skip-host-cache}.
+
+@item
+Connect to @code{localhost} if you are running the server and the client
+on the same machine.
+
+@item
+Put the client machine names in @code{/etc/hosts}.
+@end itemize
+
+@item
+If @code{mysql -u root test} works but @code{mysql -h your_hostname -u root
+test} results in @code{Access denied}, then you may not have the correct name
+for your host in the @code{user} table. A common problem here is that the
+@code{Host} value in the user table entry specifies an unqualified hostname,
+but your system's name resolution routines return a fully qualified domain
+name (or vice-versa). For example, if you have an entry with host
+@code{'tcx'} in the @code{user} table, but your DNS tells @strong{MySQL} that
+your hostname is @code{'tcx.subnet.se'}, the entry will not work. Try adding
+an entry to the @code{user} table that contains the IP number of your host as
+the @code{Host} column value. (Alternatively, you could add an entry to the
+@code{user} table with a @code{Host} value that contains a wild card---for
+example, @code{'tcx.%'}. However, use of hostnames ending with @samp{%} is
+@emph{insecure} and is @emph{not} recommended!)
+
+@item
+If @code{mysql -u user_name test} works but @code{mysql -u user_name
+other_db_name} doesn't work, you don't have an entry for @code{other_db_name}
+listed in the @code{db} table.
+
+@item
+If @code{mysql -u user_name db_name} works when executed on the server
+machine, but @code{mysql -u host_name -u user_name db_name} doesn't work when
+executed on another client machine, you don't have the client machine listed
+in the @code{user} table or the @code{db} table.
+
+@item
+If you can't figure out why you get @code{Access denied}, remove from the
+@code{user} table all entries that have @code{Host} values containing
+wild cards (entries that contain @samp{%} or @samp{_}). A very common error
+is to insert a new entry with @code{Host}=@code{'%'} and
+@code{User}=@code{'some user'}, thinking that this will allow you to specify
+@code{localhost} to connect from the same machine. The reason that this
+doesn't work is that the default privileges include an entry with
+@code{Host}=@code{'localhost'} and @code{User}=@code{''}. Because that entry
+has a @code{Host} value @code{'localhost'} that is more specific than
+@code{'%'}, it is used in preference to the new entry when connecting from
+@code{localhost}! The correct procedure is to insert a second entry with
+@code{Host}=@code{'localhost'} and @code{User}=@code{'some_user'}, or to
+remove the entry with @code{Host}=@code{'localhost'} and
+@code{User}=@code{''}.
+
+@item
+If you get the following error, you may have a problem with the @code{db} or
+@code{host} table:
+
+@example
+Access to database denied
+@end example
+
+If the entry selected from the @code{db} table has an empty value in the
+@code{Host} column, make sure there are one or more corresponding entries in
+the @code{host} table specifying which hosts the @code{db} table entry
+applies to.
+
+If you get the error when using the SQL commands @code{SELECT ...
+INTO OUTFILE} or @code{LOAD DATA INFILE}, your entry in the @code{user} table
+probably doesn't have the @strong{file} privilege enabled.
+
+@item
+@cindex configuration files
+@cindex environment variables
+@tindex .my.cnf file
+Remember that client programs will use connection parameters specified
+in configuration files or environment variables. @xref{Environment
+variables}. If a client seems to be sending the wrong default
+connection parameters when you don't specify them on the command line,
+check your environment and the @file{.my.cnf} file in your home
+directory. You might also check the system-wide @strong{MySQL}
+configuration files, though it is far less likely that client connection
+parameters will be specified there. @xref{Option files}. If you get
+@code{Access denied} when you run a client without any options, make
+sure you haven't specified an old password in any of your option files!
+@xref{Option files}.
+
+@item
+If you make changes to the grant tables directly (using an @code{INSERT} or
+@code{UPDATE} statement) and your changes seem to be ignored, remember
+that you must issue a @code{FLUSH PRIVILEGES} statement or execute a
+@code{mysqladmin flush-privileges} command to cause the server to re-read
+the privilege tables. Otherwise your changes have no effect until the
+next time the server is restarted. Remember that after you set the
+@code{root} password with an @code{UPDATE} command, you won't need to
+specify it until after you flush the privileges, because the server
+won't know you've changed the password yet!
+
+@item
+If you have access problems with a Perl, PHP, Python, or ODBC program, try to
+connect to the server with @code{mysql -u user_name db_name} or @code{mysql
+-u user_name -pyour_pass db_name}. If you are able to connect using the
+@code{mysql} client, there is a problem with your program and not with the
+access privileges. (Note that there is no space between @code{-p} and the
+password; you can also use the @code{--password=your_pass} syntax to specify
+the password. If you use the @code{-p} option alone, @strong{MySQL} will
+prompt you for the password.)
+
+@item
+For testing, start the @code{mysqld} daemon with the
+@code{--skip-grant-tables} option. Then you can change the @strong{MySQL}
+grant tables and use the @code{mysqlaccess} script to check whether or not
+your modifications have the desired effect. When you are satisfied with your
+changes, execute @code{mysqladmin flush-privileges} to tell the @code{mysqld}
+server to start using the new grant tables. @strong{Note:} Reloading the
+grant tables overrides the @code{--skip-grant-tables} option. This allows
+you to tell the server to begin using the grant tables again without bringing
+it down and restarting it.
+
+@item
+If everything else fails, start the @code{mysqld} daemon with a debugging
+option (for example, @code{--debug=d,general,query}). This will print host and
+user information about attempted connections, as well as information about
+each command issued. @xref{Making trace files}.
+
+@item
+If you have any other problems with the @strong{MySQL} grant tables and
+feel you must post the problem to the mailing list, always provide a
+dump of the @strong{MySQL} grant tables. You can dump the tables with
+the @code{mysqldump mysql} command. As always, post your problem using
+the @code{mysqlbug} script. @xref{Bug reports}. In some cases you may need
+to restart @code{mysqld} with @code{--skip-grant-tables} to run
+@code{mysqldump}.
+@end itemize
+
+
+@node User Account Management, Disaster Prevention, Privilege system, MySQL Database Administration
+@section MySQL User Account Management
+
+@menu
+* GRANT::
+* User names::
+* Privilege changes::
+* Default privileges::
+* Adding users::
+* Passwords::
+* Password security::
+@end menu
+
+
+@node GRANT, User names, User Account Management, User Account Management
+@subsection @code{GRANT} and @code{REVOKE} Syntax
+
+@findex GRANT
+@findex REVOKE
+
+@cindex privileges, granting
+@cindex privileges, revoking
+@cindex global privileges
+@cindex revoking, privleges
+@cindex granting, privleges
+
+@example
+GRANT priv_type [(column_list)] [, priv_type [(column_list)] ...]
+ ON @{tbl_name | * | *.* | db_name.*@}
+ TO user_name [IDENTIFIED BY 'password']
+ [, user_name [IDENTIFIED BY 'password'] ...]
+ [WITH GRANT OPTION]
+
+REVOKE priv_type [(column_list)] [, priv_type [(column_list)] ...]
+ ON @{tbl_name | * | *.* | db_name.*@}
+ FROM user_name [, user_name ...]
+@end example
+
+@code{GRANT} is implemented in @strong{MySQL} Version 3.22.11 or later. For
+earlier @strong{MySQL} versions, the @code{GRANT} statement does nothing.
+
+The @code{GRANT} and @code{REVOKE} commands allow system administrators
+to create users and grant and revoke rights to @strong{MySQL} users at
+four privilege levels:
+
+@table @strong
+@item Global level
+Global privileges apply to all databases on a given server. These privileges
+are stored in the @code{mysql.user} table.
+
+@item Database level
+Database privileges apply to all tables in a given database. These privileges
+are stored in the @code{mysql.db} and @code{mysql.host} tables.
+
+@item Table level
+Table privileges apply to all columns in a given table. These privileges are
+stored in the @code{mysql.tables_priv} table.
+
+@item Column level
+Column privileges apply to single columns in a given table. These privileges are
+stored in the @code{mysql.columns_priv} table.
+@end table
+
+If you give a grant for a users that doesn't exists, that user is created.
+For examples of how @code{GRANT} works, see @ref{Adding users}.
+
+For the @code{GRANT} and @code{REVOKE} statements, @code{priv_type} may be
+specified as any of the following:
+
+@example
+ALL PRIVILEGES FILE RELOAD
+ALTER INDEX SELECT
+CREATE INSERT SHUTDOWN
+DELETE PROCESS UPDATE
+DROP REFERENCES USAGE
+@end example
+
+@code{ALL} is a synonym for @code{ALL PRIVILEGES}. @code{REFERENCES} is not
+yet implemented. @code{USAGE} is currently a synonym for ``no privileges.''
+It can be used when you want to create a user that has no privileges.
+
+To revoke the @strong{grant} privilege from a user, use a @code{priv_type}
+value of @code{GRANT OPTION}:
+
+@example
+REVOKE GRANT OPTION ON ... FROM ...;
+@end example
+
+The only @code{priv_type} values you can specify for a table are @code{SELECT},
+@code{INSERT}, @code{UPDATE}, @code{DELETE}, @code{CREATE}, @code{DROP},
+@code{GRANT}, @code{INDEX}, and @code{ALTER}.
+
+The only @code{priv_type} values you can specify for a column (that is, when
+you use a @code{column_list} clause) are @code{SELECT}, @code{INSERT}, and
+@code{UPDATE}.
+
+You can set global privileges by using @code{ON *.*} syntax. You can set
+database privileges by using @code{ON db_name.*} syntax. If you specify
+@code{ON *} and you have a current database, you will set the privileges for
+that database. (@strong{WARNING:} If you specify @code{ON *} and you
+@emph{don't} have a current database, you will affect the global privileges!)
+
+In order to accommodate granting rights to users from arbitrary hosts,
+@strong{MySQL} supports specifying the @code{user_name} value in the form
+@code{user@@host}. If you want to specify a @code{user} string
+containing special characters (such as @samp{-}), or a @code{host} string
+containing special characters or wild-card characters (such as @samp{%}), you
+can quote the user or host name (for example, @code{'test-user'@@'test-hostname'}).
+
+You can specify wild cards in the hostname. For example,
+@code{user@@"%.loc.gov"} applies to @code{user} for any host in the
+@code{loc.gov} domain, and @code{user@@"144.155.166.%"} applies to @code{user}
+for any host in the @code{144.155.166} class C subnet.
+
+The simple form @code{user} is a synonym for @code{user@@"%"}.
+@strong{NOTE:} If you allow anonymous users to connect to the @strong{MySQL}
+server (which is the default), you should also add all local users as
+@code{user@@localhost} because otherwise the anonymous user entry for the
+local host in the @code{mysql.user} table will be used when the user tries to
+log into the @strong{MySQL} server from the local machine! Anonymous users
+are defined by inserting entries with @code{User=''} into the
+@code{mysql.user} table. You can verify if this applies to you by executing
+this query:
+
+@example
+mysql> SELECT Host,User FROM mysql.user WHERE User='';
+@end example
+
+For the moment, @code{GRANT} only supports host, table, database, and
+column names up to 60 characters long. A user name can be up to 16
+characters.
+
+The privileges for a table or column are formed from the
+logical OR of the privileges at each of the four privilege
+levels. For example, if the @code{mysql.user} table specifies that a
+user has a global @strong{select} privilege, this can't be denied by an
+entry at the database, table, or column level.
+
+The privileges for a column can be calculated as follows:
+
+@example
+global privileges
+OR (database privileges AND host privileges)
+OR table privileges
+OR column privileges
+@end example
+
+In most cases, you grant rights to a user at only one of the privilege
+levels, so life isn't normally as complicated as above. The details of the
+privilege-checking procedure are presented in
+@ref{Privilege system}.
+
+If you grant privileges for a user/hostname combination that does not exist
+in the @code{mysql.user} table, an entry is added and remains there until
+deleted with a @code{DELETE} command. In other words, @code{GRANT} may
+create @code{user} table entries, but @code{REVOKE} will not remove them;
+you must do that explicitly using @code{DELETE}.
+
+@cindex passwords, setting
+In @strong{MySQL} Version 3.22.12 or later,
+if a new user is created or if you have global grant privileges, the user's
+password will be set to the password specified by the @code{IDENTIFIED BY}
+clause, if one is given. If the user already had a password, it is replaced
+by the new one.
+
+@strong{WARNING:} If you create a new user but do not specify an
+@code{IDENTIFIED BY} clause, the user has no password. This is insecure.
+
+Passwords can also be set with the @code{SET PASSWORD} command.
+@xref{SET OPTION, , @code{SET OPTION}}.
+
+If you grant privileges for a database, an entry in the @code{mysql.db}
+table is created if needed. When all privileges for the database have been
+removed with @code{REVOKE}, this entry is deleted.
+
+If a user doesn't have any privileges on a table, the table is not displayed
+when the user requests a list of tables (for example, with a @code{SHOW TABLES}
+statement).
+
+The @code{WITH GRANT OPTION} clause gives the user the ability to give
+to other users any privileges the user has at the specified privilege level.
+You should be careful to whom you give the @strong{grant} privilege, as two
+users with different privileges may be able to join privileges!
+
+You cannot grant another user a privilege you don't have yourself;
+the @strong{grant} privilege allows you to give away only those privileges
+you possess.
+
+Be aware that when you grant a user the @strong{grant} privilege at a
+particular privilege level, any privileges the user already possesses (or
+is given in the future!) at that level are also grantable by that user.
+Suppose you grant a user the @strong{insert} privilege on a database. If
+you then grant the @strong{select} privilege on the database and specify
+@code{WITH GRANT OPTION}, the user can give away not only the @strong{select}
+privilege, but also @strong{insert}. If you then grant the @strong{update}
+privilege to the user on the database, the user can give away the
+@strong{insert}, @strong{select} and @strong{update}.
+
+You should not grant @strong{alter} privileges to a normal user. If you
+do that, the user can try to subvert the privilege system by renaming
+tables!
+
+Note that if you are using table or column privileges for even one user, the
+server examines table and column privileges for all users and this will slow
+down @strong{MySQL} a bit.
+
+When @code{mysqld} starts, all privileges are read into memory.
+Database, table, and column privileges take effect at once, and
+user-level privileges take effect the next time the user connects.
+Modifications to the grant tables that you perform using @code{GRANT} or
+@code{REVOKE} are noticed by the server immediately.
+If you modify the grant tables manually (using @code{INSERT}, @code{UPDATE},
+etc.), you should execute a @code{FLUSH PRIVILEGES} statement or run
+@code{mysqladmin flush-privileges} to tell the server to reload the grant
+tables.
+@xref{Privilege changes}.
+
+@cindex ANSI SQL, differences from
+The biggest differences between the ANSI SQL and @strong{MySQL} versions of
+@code{GRANT} are:
+
+@itemize @bullet
+@item
+In @strong{MySQL} privileges are given for an username + hostname combination
+and not only for an username.
+
+@item
+ANSI SQL doesn't have global or database-level privileges, and ANSI SQL
+doesn't support all privilege types that @strong{MySQL} supports.
+@strong{MySQL} doesn't support the ANSI SQL @code{TRIGGER}, @code{EXECUTE} or
+@code{UNDER} privileges.
+
+@item
+ANSI SQL privileges are structured in a hierarchal manner. If you remove
+an user, all privileges the user has granted are revoked. In
+@strong{MySQL} the granted privileges are not automatically revoked, but
+you have to revoke these yourself if needed.
+
+@item
+If you in @strong{MySQL} have the @code{INSERT} grant on only part of the
+columns in a table, you can execute @code{INSERT} statements on the
+table; The columns for which you don't have the @code{INSERT} privilege
+will set to their default values. ANSI SQL requires you to have the
+@code{INSERT} privilege on all columns.
+
+@item
+When you drop a table in ANSI SQL, all privileges for the table are revoked.
+If you revoke a privilege in ANSI SQL, all privileges that were granted based
+on this privilege are also revoked. In @strong{MySQL}, privileges can be
+dropped only with explicit @code{REVOKE} commands or by manipulating the
+@strong{MySQL} grant tables.
+@end itemize
+
+
+@node User names, Privilege changes, GRANT, User Account Management
+@subsection MySQL User Names and Passwords
+
+@cindex user names, and passwords
+@cindex passwords, for users
+
+There are several distinctions between the way user names and passwords are
+used by @strong{MySQL} and the way they are used by Unix or Windows:
+
+@itemize @bullet
+@item
+User names, as used by @strong{MySQL} for authentication purposes, have
+nothing to do with Unix user names (login names) or Windows user names. Most
+@strong{MySQL} clients by default try to log in using the current Unix user
+name as the @strong{MySQL} user name, but that is for convenience only.
+Client programs allow a different name to be specified with the @code{-u} or
+@code{--user} options. This means that you can't make a database secure in
+any way unless all @strong{MySQL} user names have passwords. Anyone may
+attempt to connect to the server using any name, and they will succeed if
+they specify any name that doesn't have a password.
+
+@item
+@strong{MySQL} user names can be up to 16 characters long; Unix user names
+typically are limited to 8 characters.
+
+@item
+@strong{MySQL} passwords have nothing to do with Unix passwords. There is no
+necessary connection between the password you use to log in to a Unix machine
+and the password you use to access a database on that machine.
+
+@item
+@strong{MySQL} encrypts passwords using a different algorithm than the
+one used during the Unix login process. See the descriptions of the
+@code{PASSWORD()} and @code{ENCRYPT()} functions in @ref{Miscellaneous
+functions}. Note that even if the password is stored 'scrambled', and
+knowing your 'scrambled' password is enough to be able to connect to
+the @strong{MySQL} server!
+@end itemize
+
+@strong{MySQL} users and they privileges are normally created with the
+@code{GRANT} command. @xref{GRANT}.
+
+When you login to a @strong{MySQL} server with a command line client you
+should specify the password with @code{--password=your-password}.
+@xref{Connecting}.
+
+@example
+mysql --user=monty --password=guess database_name
+@end example
+
+If you want the client to prompt for a password, you should use
+@code{--password} without any argument
+
+@example
+mysql --user=monty --password database_name
+@end example
+
+or the short form:
+
+@example
+mysql -u monty -p database_name
+@end example
+
+Note that in the last example the password is @strong{NOT} 'database_name'.
+
+If you want to use the @code{-p} option to supply a password you should do like this:
+
+@example
+mysql -u monty -pguess database_name
+@end example
+
+On some system the library call that @strong{MySQL} uses to prompt for a
+password will automatically cut the password to 8 characters. Internally
+@strong{MySQL} doesn't have any limit for the length of the password.
+
+
+@node Privilege changes, Default privileges, User names, User Account Management
+@subsection When Privilege Changes Take Effect
When @code{mysqld} starts, all grant table contents are read into memory and
become effective at that point.
@@ -15700,6 +16876,10 @@ command.
Global privilege changes and password changes take effect the next time the
client connects.
+
+@node Default privileges, Adding users, Privilege changes, User Account Management
+@subsection Setting Up the Initial MySQL Privileges
+
@cindex privileges, default
@cindex default, privileges
@cindex root password
@@ -15707,8 +16887,6 @@ client connects.
@cindex users, root
@cindex anonymous user
@cindex password, root user
-@node Default privileges, Adding users, Privilege changes, Privilege system
-@section Setting Up the Initial MySQL Privileges
After installing @strong{MySQL}, you set up the initial access privileges by
running @code{scripts/mysql_install_db}.
@@ -15804,13 +16982,16 @@ you should NOT delete the @file{.frm} files. If you accidentally do this,
you should copy them back from your @strong{MySQL} distribution before
running @code{mysql_install_db}.
+
+@node Adding users, Passwords, Default privileges, User Account Management
+@subsection Adding New Users to MySQL
+
+@findex GRANT statement
+@findex statements, GRANT
+
@cindex privileges, adding
@cindex adding, new user privileges
@cindex user privileges, adding
-@findex GRANT statement
-@findex statements, GRANT
-@node Adding users, Passwords, Default privileges, Privilege system
-@section Adding New Users to MySQL
You can add users two different ways: by using @code{GRANT} statements
or by manipulating the @strong{MySQL} grant tables directly. The
@@ -15996,12 +17177,15 @@ You can find these utilities in the
@uref{http://www.mysql.com/Downloads/Contrib/,Contrib directory of the @strong{MySQL}
Website}.
-@cindex passwords, setting
+
+@node Passwords, Password security, Adding users, User Account Management
+@subsection Setting Up Passwords
+
@findex PASSWORD()
@findex SET PASSWORD statement
+
+@cindex passwords, setting
@cindex setting, passwords
-@node Passwords, Access denied, Adding users, Privilege system
-@section Setting Up Passwords
In most cases you should use @code{GRANT} to set up your users/passwords,
so the following only applies for advanced users. @xref{GRANT, , @code{GRANT}}.
@@ -16071,319 +17255,6373 @@ your Unix password and your @strong{MySQL} password are the same, that
@code{PASSWORD()} will result in the same encrypted value as is stored in the
Unix password file. @xref{User names}.
-@node Access denied, , Passwords, Privilege system
-@section Causes of @code{Access denied} Errors
-If you encounter @code{Access denied} errors when you try to connect to the
-@strong{MySQL} server, the list below indicates some courses of
-action you can take to correct the problem:
+@node Password security, , Passwords, User Account Management
+@subsection Keeping Your Password Secure
+
+It is inadvisable to specify your password in a way that exposes it to
+discovery by other users. The methods you can use to specify your password
+when you run client programs are listed below, along with an assessment of
+the risks of each method:
@itemize @bullet
@item
-After installing @strong{MySQL}, did you run the @code{mysql_install_db}
-script to set up the initial grant table contents? If not, do so.
-@xref{Default privileges}. Test the initial privileges by executing
-this command:
+Never give a normal user access to the @code{mysql.user} table. Knowing
+the encrypted password for a user makes it possible to login as this
+user. The passwords are only scrambled so that one shouldn't be able to
+see the real password you used (if you happen to use a similar password
+with your other applications).
+
+@item
+Use a @code{-pyour_pass} or @code{--password=your_pass} option on the command
+line. This is convenient but insecure, because your password becomes visible
+to system status programs (such as @code{ps}) that may be invoked by other
+users to display command lines. (@strong{MySQL} clients typically overwrite
+the command-line argument with zeroes during their initialization sequence,
+but there is still a brief interval during which the value is visible.)
+
+@item
+Use a @code{-p} or @code{--password} option (with no @code{your_pass} value
+specified). In this case, the client program solicits the password from
+the terminal:
+@findex -p option
+@findex -password option
@example
-shell> mysql -u root test
+shell> mysql -u user_name -p
+Enter password: ********
@end example
-The server should let you connect without error. You should also make sure
-you have a file @file{user.MYD} in the @strong{MySQL} database directory.
-Ordinarily, this is @file{PATH/var/mysql/user.MYD}, where @code{PATH} is the
-pathname to the @strong{MySQL} installation root.
+The @samp{*} characters represent your password.
+
+It is more secure to enter your password this way than to specify it on the
+command line because it is not visible to other users. However, this method
+of entering a password is suitable only for programs that you run
+interactively. If you want to invoke a client from a script that runs
+non-interactively, there is no opportunity to enter the password from the
+terminal. On some systems, you may even find that the first line of your
+script is read and interpreted (incorrectly) as your password!
@item
-After a fresh installation, you should connect to the server and set up
-your users and their access permissions:
+@tindex .my.cnf file
+Store your password in a configuration file. For example, you can list your
+password in the @code{[client]} section of the @file{.my.cnf} file in your
+home directory:
@example
-shell> mysql -u root mysql
+[client]
+password=your_pass
@end example
-The server should let you connect because the @strong{MySQL} @code{root} user
-has no password initially. That is also a security risk, so setting the
-@code{root} password is something you should do while you're setting up
-your other @strong{MySQL} users.
+If you store your password in @file{.my.cnf}, the file should not be group or
+world readable or writable. Make sure the file's access mode is @code{400}
+or @code{600}.
-If you try to connect as @code{root} and get this error:
+@xref{Option files}.
+@item
+You can store your password in the @code{MYSQL_PWD} environment variable, but
+this method must be considered extremely insecure and should not be used.
+Some versions of @code{ps} include an option to display the environment of
+running processes; your password will be in plain sight for all to see if
+you set @code{MYSQL_PWD}. Even on systems without such a version of
+@code{ps}, it is unwise to assume there is no other method to observe process
+environments. @xref{Environment variables}.
+@end itemize
+
+All in all, the safest methods are to have the client program prompt for the
+password or to specify the password in a properly protected @file{.my.cnf}
+file.
+
+
+@node Disaster Prevention, Database Administration, User Account Management, MySQL Database Administration
+@section Disaster Prevention and Recovery
+
+@menu
+* Backup::
+* BACKUP TABLE::
+* RESTORE TABLE::
+* CHECK TABLE::
+* REPAIR TABLE::
+* Table maintenance::
+* Maintenance regimen::
+* Table-info::
+@end menu
+
+
+@node Backup, BACKUP TABLE, Disaster Prevention, Disaster Prevention
+@subsection Database Backups
+
+@cindex databases, backups
+@cindex backups
+
+Because @strong{MySQL} tables are stored as files, it is easy to do a
+backup. To get a consistent backup, do a @code{LOCK TABLES} on the
+relevant tables followed by @code{FLUSH TABLES} for the tables.
+@xref{LOCK TABLES, , @code{LOCK TABLES}}.
+@xref{FLUSH, , @code{FLUSH}}.
+You only need a read lock; this allows other threads to continue to
+query the tables while you are making a copy of the files in the
+database directory. The @code{FLUSH TABLE} is needed to ensure that
+the all active index pages is written to disk before you start the backup.
+
+If you want to make a SQL level backup of a table, you can use
+@code{SELECT INTO OUTFILE} or @code{BACKUP TABLE}. @xref{SELECT}.
+@xref{BACKUP TABLE}.
+
+Another way to back up a database is to use the @code{mysqldump} program or
+the @code{mysqlhotcopy script}. @xref{mysqldump, , @code{mysqldump}}.
+@xref{mysqlhotcopy, , @code{mysqlhotcopy}}.
+
+@enumerate
+@item
+Do a full backup of your databases:
@example
-Access denied for user: '@@unknown' to database mysql
+shell> mysqldump --tab=/path/to/some/dir --opt --full
+
+or
+
+shell> mysqlhotcopy database /path/to/some/dir
@end example
-this means that you don't have an entry in the @code{user} table with a
-@code{User} column value of @code{'root'} and that @code{mysqld} cannot
-resolve the hostname for your client. In this case, you must restart the
-server with the @code{--skip-grant-tables} option and edit your
-@file{/etc/hosts} or @file{\windows\hosts} file to add an entry for your
-host.
+You can also simply copy all table files (@file{*.frm}, @file{*.MYD}, and
+@file{*.MYI} files) as long as the server isn't updating anything.
+The script @code{mysqlhotcopy} does use this method.
@item
-If you get an error like the following:
+@cindex log files, names
+Stop @code{mysqld} if it's running, then start it with the
+@code{--log-update[=file_name]} option. @xref{Update log}. The update
+log file(s) provide you with the information you need to replicate
+changes to the database that are made subsequent to the point at which
+you executed @code{mysqldump}.
+@end enumerate
+
+If you have to restore something, try to recover your tables using
+@code{REPAIR TABLE} or @code{myisamchk -r} first. That should work in
+99.9% of all cases. If @code{myisamchk} fails, try the following
+procedure: (This will only work if you have started @strong{MySQL} with
+@code{--log-update}. @xref{Update log}.):
+
+@enumerate
+@item
+Restore the original @code{mysqldump} backup.
+@item
+Execute the following command to re-run the updates in the binary log:
@example
-shell> mysqladmin -u root -pxxxx ver
-Access denied for user: 'root@@localhost' (Using password: YES)
+shell> mysqlbinlog hostname-bin.[0-9]* | mysql
@end example
-It means that you are using a wrong password. @xref{Passwords}.
+If you are using the update log you can use:
-If you have forgot the root password, you can restart @code{mysqld} with
-@code{--skip-grant-tables} to change the password. You can find more
-about this option later on in this manual section.
+@example
+shell> ls -1 -t -r hostname.[0-9]* | xargs cat | mysql
+@end example
+@end enumerate
-If you get the above error even if you haven't specified a password,
-this means that you a wrong password in some @code{my.ini}
-file. @xref{Option files}. You can avoid using option files with the @code{--no-defaults} option, as follows:
+@code{ls} is used to get all the update log files in the right order.
+
+You can also do selective backups with @code{SELECT * INTO OUTFILE 'file_name'
+FROM tbl_name} and restore with @code{LOAD DATA INFILE 'file_name' REPLACE
+...} To avoid duplicate records, you need a @code{PRIMARY KEY} or a
+@code{UNIQUE} key in the table. The @code{REPLACE} keyword causes old records
+to be replaced with new ones when a new record duplicates an old record on
+a unique key value.
+
+If you get performance problems in making backups on your system, you can
+solve this by setting up replication and do the backups on the slave
+instead of on the master. @xref{Replication Intro}.
+
+If you are using a Veritas file system, you can do:
+
+@enumerate
+@item
+Execute in a client (perl ?) @code{FLUSH TABLES WITH READ LOCK}
+
+@item
+Fork a shell or execute in another client @code{mount vxfs snapshot}.
+
+@item
+Execute in the first client @code{UNLOCK TABLES}
+
+@item
+Copy files from snapshot
+
+@item
+Unmount snapshot
+@end enumerate
+
+
+@node BACKUP TABLE, RESTORE TABLE, Backup, Disaster Prevention
+@subsection @code{BACKUP TABLE} Syntax
+
+@findex BACKUP TABLE
+
+@cindex backups, database
@example
-shell> mysqladmin --no-defaults -u root ver
+BACKUP TABLE tbl_name[,tbl_name...] TO '/path/to/backup/directory'
+@end example
+
+Make a copy of all the table files to the backup directory that are the
+minimum needed to restore it. Currenlty only works for @code{MyISAM}
+tables. For @code{MyISAM} table, copies @code{.frm} (definition) and
+@code{.MYD} (data) files. The index file can be rebuilt from those two.
+
+Before using this command, please see @xref{Backup}.
+
+During the backup, read lock will be held for each table, one at time,
+as they are being backed up. If you want to backup several tables as
+a snapshot, you must first issue @code{LOCK TABLES} obtaining a read
+lock for each table in the group.
+
+The command returns a table with the following columns:
+
+@multitable @columnfractions .35 .65
+@item @strong{Column} @tab @strong{Value}
+@item Table @tab Table name
+@item Op @tab Always ``backup''
+@item Msg_type @tab One of @code{status}, @code{error}, @code{info} or @code{warning}.
+@item Msg_text @tab The message.
+@end multitable
+
+Note that @code{BACKUP TABLE} is only available in @strong{MySQL}
+version 3.23.25 and later.
+
+
+@node RESTORE TABLE, CHECK TABLE, BACKUP TABLE, Disaster Prevention
+@subsection @code{RESTORE TABLE} Syntax
+
+@findex RESTORE TABLE
+
+@example
+RESTORE TABLE tbl_name[,tbl_name...] FROM '/path/to/backup/directory'
@end example
+Restores the table(s) from the backup that was made with
+@code{BACKUP TABLE}. Existing tables will not be overwritten - if you
+try to restore over an existing table, you will get an error. Restore
+will take longer than BACKUP due to the need to rebuilt the index. The
+more keys you have, the longer it is going to take. Just as
+@code{BACKUP TABLE}, currently only works of @code{MyISAM} tables.
+
+
+The command returns a table with the following columns:
+
+@multitable @columnfractions .35 .65
+@item @strong{Column} @tab @strong{Value}
+@item Table @tab Table name
+@item Op @tab Always ``restore''
+@item Msg_type @tab One of @code{status}, @code{error}, @code{info} or @code{warning}.
+@item Msg_text @tab The message.
+@end multitable
+
+
+@node CHECK TABLE, REPAIR TABLE, RESTORE TABLE, Disaster Prevention
+@subsection @code{CHECK TABLE} Syntax
+
+@findex CHECK TABLE
+
+@example
+CHECK TABLE tbl_name[,tbl_name...] [option [option...]]
+
+option = QUICK | FAST | MEDIUM | EXTEND | CHANGED
+@end example
+
+@code{CHECK TABLE} only works on @code{MyISAM} tables. On
+@code{MyISAM} tables it's the same thing as running @code{myisamchk -m
+table_name} on the table.
+
+If you don't specify any option @code{MEDIUM} is used.
+
+Checks the table(s) for errors. For @code{MyISAM} tables the key statistics
+is updated. The command returns a table with the following columns:
+
+@multitable @columnfractions .35 .65
+@item @strong{Column} @tab @strong{Value}
+@item Table @tab Table name.
+@item Op @tab Always ``check''.
+@item Msg_type @tab One of @code{status}, @code{error}, @code{info}, or @code{warning}.
+@item Msg_text @tab The message.
+@end multitable
+
+Note that you can get many rows of information for each checked
+table. The last row will be of @code{Msg_type status} and should
+normally be @code{OK}. If you don't get @code{OK}, or @code{Not
+checked} you should normally run a repair of the table. @xref{Table
+maintenance}. @code{Not checked} means that the table the given @code{TYPE}
+told @strong{MySQL} that there wasn't any need to check the table.
+
+The different check types stand for the following:
+
+@multitable @columnfractions .20 .80
+@item @strong{Type} @tab @strong{Meaning}
+@item @code{QUICK} @tab Don't scan the rows to check for wrong links.
+@item @code{FAST} @tab Only check tables which haven't been closed properly.
+@item @code{CHANGED} @tab Only check tables which have been changed since last check or haven't been closed properly.
+@item @code{MEDIUM} @tab Scan rows to verify that deleted links are ok. This also calculates a key checksum for the rows and verifies this with a calcualted checksum for the keys.
+@item @code{EXTENDED} @tab Do a full key lookup for all keys for each row. This ensures that the table is 100 % consistent, but will take a long time!
+@end multitable
+
+For dynamic sized @code{MyISAM} tables a started check will always
+do a @code{MEDIUM} check. For static size rows we skip the row scan
+for @code{QUICK} and @code{FAST} as the rows are very seldom corrupted.
+
+You can combine check options as in:
+
+@example
+CHECK TABLE test_table FAST QUICK;
+@end example
+
+Which only would do a quick check on the table if it wasn't closed properly.
+
+@strong{NOTE:} that in some case @code{CHECK TABLE} will change the
+table! This happens if the table is marked as 'corrupted' or 'not
+closed properly' but @code{CHECK TABLE} didn't find any problems in the
+table. In this case @code{CHECK TABLE} will mark the table as ok.
+
+If a table is corrupted, then it's most likely that the problem is in
+the indexes and not in the data part. All of the above check types
+checks the indexes throughly and should thus find most errors.
+
+If you just want to check a table that you assume is ok, you should use
+no check options or the @code{QUICK} option. The later should be used
+when you are in a hurry and can take the very small risk that
+@code{QUICK} didn't find an error in the data file (In most cases
+@strong{MySQL} should find, under normal usage, any error in the data
+file. If this happens then the table will be marked as 'corrupted',
+in which case the table can't be used until it's repaired).
+
+@code{FAST} and @code{CHANGED} are mostly intended to be used from a
+script (for example to be executed from cron) if you want to check your
+table from time to time. In most cases you @code{FAST} is to be prefered
+over @code{CHANGED}. (The only case when it isn't is when you suspect a
+bug you have found a bug in the @code{MyISAM} code.).
+
+@code{EXTENDED} is only to be used after you have run a normal check but
+still get strange errors from a table when @strong{MySQL} tries to
+update a row or find a row by key (this is VERY unlikely to happen if a
+normal check has succeeded!).
+
+Some things reported by check table, can't be corrected automatically:
+
+@itemize @bullet
@item
-@cindex @code{mysql_fix_privilege_tables}
-If you updated an existing @strong{MySQL} installation from a version earlier
-than Version 3.22.11 to Version 3.22.11 or later, did you run the
-@code{mysql_fix_privilege_tables} script? If not, do so. The structure of
-the grant tables changed with @strong{MySQL} Version 3.22.11 when the
-@code{GRANT} statement became functional.
+@code{Found row where the auto_increment column has the value 0}.
+
+This means that you have in the table a row where the
+@code{auto_increment} index column contains the value 0.
+(It's possible to create a row where the auto_increment column is 0 by
+explicitely setting the column to 0 with an @code{UPDATE} statement)
+
+This isn't an error in itself, but could cause trouble if you decide to
+dump the table and restore it or do an @code{ALTER TABLE} on the
+table. In this case the auto_increment column will change value,
+according to the rules of auto_increment columns, which could cause
+problems like a duplicate key error.
+
+To get rid of the warning, just execute an @code{UPDATE} statement
+to set the column to some other value than 0.
+@end itemize
+
+
+@node REPAIR TABLE, Table maintenance, CHECK TABLE, Disaster Prevention
+@subsection @code{REPAIR TABLE} Syntax
+
+@findex REPAIR TABLE
+
+@example
+REPAIR TABLE tbl_name[,tbl_name...] [QUICK] [EXTENDED]
+@end example
+
+@code{REPAIR TABLE} only works on @code{MyISAM} tables and is the same
+as running @code{myisamchk -r table_name} on the table.
+
+Normally you should never have to run this command, but if disaster strikes
+you are very likely to get back all your data from a MyISAM table with
+@code{REPAIR TABLE}. If your tables get corrupted a lot you should
+try to find the reason for this! @xref{Crashing}. @xref{MyISAM table problems}.
+
+@code{REPAIR TABLE} repairs a possible corrupted table. The command returns a
+table with the following columns:
+
+@multitable @columnfractions .35 .65
+@item @strong{Column} @tab @strong{Value}
+@item Table @tab Table name
+@item Op @tab Always ``repair''
+@item Msg_type @tab One of @code{status}, @code{error}, @code{info} or @code{warning}.
+@item Msg_text @tab The message.
+@end multitable
+
+Note that you can get many rows of information for each repaired
+table. The last one row will be of @code{Msg_type status} and should
+normally be @code{OK}. If you don't get @code{OK}, you should try
+repairing the table with @code{myisamchk -o}, as @code{REPAIR TABLE}
+does not yet implement all the options of @code{myisamchk}. In the near
+future, we will make it more flexible.
+
+If @code{QUICK} is given then @strong{MySQL} will try to do a
+@code{REPAIR} of only the index tree.
+
+If you use @code{EXTENDED} then @strong{MySQL} will create the index row
+by row instead of creating one index at a time with sorting; This may be
+better than sorting on fixed-length keys if you have long @code{char()}
+keys that compress very good.
+
+
+@node Table maintenance, Maintenance regimen, REPAIR TABLE, Disaster Prevention
+@subsection Using @code{myisamchk} for Table Maintenance and Crash Recovery
+
+Starting with @strong{MySQL} Version 3.23.13, you can check MyISAM
+tables with the @code{CHECK TABLE} command. @xref{CHECK TABLE}. You can
+repair tables with the @code{REPAIR TABLE} command. @xref{REPAIR TABLE}.
+
+To check/repair MyISAM tables (@code{.MYI} and @code{.MYD}) you should
+use the @code{myisamchk} utility. To check/repair ISAM tables
+(@code{.ISM} and @code{.ISD}) you should use the @code{isamchk}
+utility. @xref{Table types}.
+
+In the following text we will talk about @code{myisamchk}, but everything
+also applies to the old @code{isamchk}.
+
+You can use the @code{myisamchk} utility to get information about your
+database tables, check and repair them, or optimize them. The following
+sections describe how to invoke @code{myisamchk} (including a
+description of its options), how to set up a table maintenance schedule,
+and how to use @code{myisamchk} to perform its various functions.
+
+You can, in most cases, also use the command @code{OPTIMIZE TABLES} to
+optimize and repair tables, but this is not as fast or reliable (in case
+of real fatal errors) as @code{myisamchk}. On the other hand,
+@code{OPTIMIZE TABLE} is easier to use and you don't have to worry about
+flushing tables.
+@xref{OPTIMIZE TABLE, , @code{OPTIMIZE TABLE}}.
+
+Even that the repair in @code{myisamchk} is quite secure, it's always a
+good idea to make a backup BEFORE doing a repair (or anything that could
+make a lot of changes to a table)
+
+@menu
+* myisamchk syntax::
+* myisamchk general options::
+* myisamchk check options::
+* myisamchk repair options::
+* myisamchk other options::
+* myisamchk memory::
+* Crash recovery::
+* Check::
+* Repair::
+* Optimization::
+@end menu
+
+@node myisamchk syntax, myisamchk general options, Table maintenance, Table maintenance
+@subsubsection @code{myisamchk} Invocation Syntax
+
+@code{myisamchk} is invoked like this:
+
+@example
+shell> myisamchk [options] tbl_name
+@end example
+
+The @code{options} specify what you want @code{myisamchk} to do. They are
+described below. (You can also get a list of options by invoking
+@code{myisamchk --help}.) With no options, @code{myisamchk} simply checks your
+table. To get more information or to tell @code{myisamchk} to take corrective
+action, specify options as described below and in the following sections.
+
+@code{tbl_name} is the database table you want to check/repair. If you run
+@code{myisamchk} somewhere other than in the database directory, you must
+specify the path to the file, because @code{myisamchk} has no idea where your
+database is located. Actually, @code{myisamchk} doesn't care whether or not
+the files you are working on are located in a database directory; you can
+copy the files that correspond to a database table into another location and
+perform recovery operations on them there.
+
+You can name several tables on the @code{myisamchk} command line if you
+wish. You can also specify a name as an index file
+name (with the @file{.MYI} suffix), which allows you to specify all
+tables in a directory by using the pattern @file{*.MYI}.
+For example, if you are in a database directory, you can check all the
+tables in the directory like this:
+
+@example
+shell> myisamchk *.MYI
+@end example
+
+If you are not in the database directory, you can check all the tables there
+by specifying the path to the directory:
+@example
+shell> myisamchk /path/to/database_dir/*.MYI
+@end example
+
+You can even check all tables in all databases by specifying a wild card
+with the path to the @strong{MySQL} data directory:
+
+@example
+shell> myisamchk /path/to/datadir/*/*.MYI
+@end example
+
+The recommended way to quickly check all tables is:
+
+@example
+myisamchk --silent --fast /path/to/datadir/*/*.MYI
+isamchk --silent /path/to/datadir/*/*.ISM
+@end example
+
+If you want to check all tables and repair all tables that are corrupted,
+you can use the following line:
+
+@example
+myisamchk --silent --force --fast --update-state -O key_buffer=64M -O sort_buffer=64M -O read_buffer=1M -O write_buffer=1M /path/to/datadir/*/*.MYI
+isamchk --silent --force -O key_buffer=64M -O sort_buffer=64M -O read_buffer=1M -O write_buffer=1M /path/to/datadir/*/*.ISM
+@end example
+
+The above assumes that you have more than 64 M free.
+
+Note that if you get an error like:
+
+@example
+myisamchk: warning: 1 clients is using or hasn't closed the table properly
+@end example
+
+This means that you are trying to check a table that has been updated by
+the another program (like the @code{mysqld} server) that hasn't yet closed
+the file or that has died without closing the file properly.
+
+If you @code{mysqld} is running, you must force a sync/close of all
+tables with @code{FLUSH TABLES} and ensure that no one is using the
+tables while you are running @code{myisamchk}. In @strong{MySQL} Version 3.23
+the easiest way to avoid this problem is to use @code{CHECK TABLE}
+instead of @code{myisamchk} to check tables.
+
+@menu
+* myisamchk general options::
+* myisamchk check options::
+* myisamchk repair options::
+* myisamchk other options::
+@end menu
+
+
+@node myisamchk general options, myisamchk check options, myisamchk syntax, Table maintenance
+@subsubsection General Options for @code{myisamchk}
+
+@cindex options, @code{myisamchk}
+@cindex @code{myisamchk}, options
+
+@code{myisamchk} supports the following options.
+
+@table @code
+@item -# or --debug=debug_options
+Output debug log. The @code{debug_options} string often is
+@code{'d:t:o,filename'}.
+@item -? or --help
+Display a help message and exit.
+@item -O var=option, --set-variable var=option
+Set the value of a variable. The possible variables and their default values
+for myisamchk can be examined with @code{myisamchk --help}:
+@multitable @columnfractions .3 .7
+@item key_buffer_size @tab 523264
+@item read_buffer_size @tab 262136
+@item write_buffer_size @tab 262136
+@item sort_buffer_size @tab 2097144
+@item sort_key_blocks @tab 16
+@item decode_bits @tab 9
+@end multitable
+
+@code{sort_buffer_size} is used when the keys are repaired by sorting
+keys, which is the normal case when you use @code{--recover}.
+
+@code{key_buffer_size} is used when you are checking the table with
+@code{--extended-check} or when the keys are repaired by inserting key
+row by row in to the table (like when doing normal inserts). Repairing
+through the key buffer is used in the following cases:
+
+@itemize @bullet
@item
-If your privileges seem to have changed in the middle of a session, it may be
-that a superuser has changed them. Reloading the grant tables affects new
-client connections, but it also affects existing connections as indicated in
-@ref{Privilege changes}.
+If you use @code{--safe-recover}.
+@item
+If you are using a @code{FULLTEXT} index.
+@item
+If the temporary files needed to sort the keys would be more than twice
+as big as when creating the key file directly. This is often the case
+when you have big @code{CHAR}, @code{VARCHAR} or @code{TEXT} keys as the
+sort needs to store the whole keys during sorting. If you have lots
+of temporary space and you can force @code{myisamchk} to repair by sorting
+you can use the @code{--sort-recover} option.
+@end itemize
+
+Reparing through the key buffer takes much less disk space than using
+sorting, but is also much slower.
+
+If you want a faster repair, set the above variables to about 1/4 of your
+available memory. You can set both variables to big values, as only one
+of the above buffers will be used at a time.
+
+@item -s or --silent
+Silent mode. Write output only when errors occur. You can use @code{-s}
+twice (@code{-ss}) to make @code{myisamchk} very silent.
+@item -v or --verbose
+Verbose mode. Print more information. This can be used with @code{-d} and
+@code{-e}. Use @code{-v} multiple times (@code{-vv}, @code{-vvv}) for more
+verbosity!
+@item -V or --version
+Print the @code{myisamchk} version and exit.
+@item -w or, --wait
+Instead of giving an error if the table is locked, wait until the table
+is unlocked before continuing. Note that if you are running @code{mysqld}
+on the table with @code{--skip-locking}, the table can only be locked
+by another @code{myisamchk} command.
+@end table
+
+
+@node myisamchk check options, myisamchk repair options, myisamchk general options, Table maintenance
+@subsubsection Check Options for @code{myisamchk}
+
+@cindex check options, myisamchk
+@cindex tables, checking
+
+@table @code
+@item -c or --check
+Check table for errors. This is the default operation if you are not
+giving @code{myisamchk} any options that override this.
+
+@item -e or --extend-check
+Check the table VERY thoroughly (which is quite slow if you have many
+indexes). This option should only be used in extreme cases. Normally,
+@code{myisamchk} or @code{myisamchk --medium-check} should, in most
+cases, be able to find out if there are any errors in the table.
+
+If you are using @code{--extended-check} and have much memory, you should
+increase the value of @code{key_buffer_size} a lot!
+
+@item -F or --fast
+Check only tables that haven't been closed properly.
+@item -C or --check-only-changed
+Check only tables that have changed since the last check.
+@item -f or --force
+Restart @code{myisamchk} with @code{-r} (repair) on the table, if
+@code{myisamchk} finds any errors in the table.
+@item -i or --information
+Print informational statistics about the table that is checked.
+@item -m or --medium-check
+Faster than extended-check, but only finds 99.99% of all errors.
+Should, however, be good enough for most cases.
+@item -U or --update-state
+Store in the @file{.MYI} file when the table was checked and if the table crashed. This should be used to get full benefit of the
+@code{--check-only-changed} option, but you shouldn't use this
+option if the @code{mysqld} server is using the table and you are
+running @code{mysqld} with @code{--skip-locking}.
+@item -T or --read-only
+Don't mark table as checked. This is useful if you use @code{myisamchk}
+to check a table that is in use by some other application that doesn't
+use locking (like @code{mysqld --skip-locking}).
+@end table
+
+
+@node myisamchk repair options, myisamchk other options, myisamchk check options, Table maintenance
+@subsubsection Repair Options for myisamchk
+
+@cindex repair options, myisamchk
+@cindex files, repairing
+
+The following options are used if you start @code{myisamchk} with
+@code{-r} or @code{-o}:
+
+@table @code
+@item -D # or --data-file-length=#
+Max length of data file (when re-creating data file when it's 'full').
+@item -e or --extend-check
+Try to recover every possible row from the data file.
+Normally this will also find a lot of garbage rows. Don't use this option
+if you are not totally desperate.
+@item -f or --force
+Overwrite old temporary files (@code{table_name.TMD}) instead of aborting.
+@item -k # or keys-used=#
+If you are using ISAM, tells the ISAM table handler to update only the
+first @code{#} indexes. If you are using @code{MyISAM}, tells which keys
+to use, where each binary bit stands for one key (first key is bit 0).
+This can be used to get faster inserts! Deactivated indexes can be
+reactivated by using @code{myisamchk -r}. keys.
+@item -l or --no-symlinks
+Do not follow symbolic links. Normally @code{myisamchk} repairs the
+table a symlink points at. This option doesn't exist in MySQL 4.0,
+as MySQL 4.0 will not remove symlinks during repair.
+@item -r or --recover
+Can fix almost anything except unique keys that aren't unique
+(which is an extremely unlikely error with ISAM/MyISAM tables).
+If you want to recover a table, this is the option to try first. Only if
+myisamchk reports that the table can't be recovered by @code{-r}, you
+should then try @code{-o}. (Note that in the unlikely case that @code{-r}
+fails, the data file is still intact.)
+If you have lots of memory, you should increase the size of
+@code{sort_buffer_size}!
+@item -o or --safe-recover
+Uses an old recovery method (reads through all rows in order and updates
+all index trees based on the found rows); this is a magnitude slower
+than @code{-r}, but can handle a couple of very unlikely cases that
+@code{-r} cannot handle. This recovery method also uses much less disk
+space than @code{-r}. Normally one should always first repair with
+@code{-r}, and only if this fails use @code{-o}.
+
+If you have lots of memory, you should increase the size of
+@code{key_buffer_size}!
+@item -n or --sort-recover
+Force @code{myisamchk} to use sorting to resolve the keys even if the
+temporary files should be very big. This will not have any effect if you have
+fulltext keys in the table.
+@item --character-sets-dir=...
+Directory where character sets are stored.
+@item --set-character-set=name
+Change the character set used by the index
+@item .t or --tmpdir=path
+Path for storing temporary files. If this is not set, @code{myisamchk} will
+use the environment variable @code{TMPDIR} for this.
+@item -q or --quick
+Faster repair by not modifying the data file. One can give a second
+@code{-q} to force @code{myisamchk} to modify the original datafile in case
+of duplicate keys
+@item -u or --unpack
+Unpack file packed with myisampack.
+@end table
+
+@node myisamchk other options, myisamchk memory, myisamchk repair options, Table maintenance
+@subsubsection Other Options for @code{myisamchk}
+
+Other actions that @code{myisamchk} can do, besides repair and check tables:
+
+@table @code
+@item -a or --analyze
+Analyze the distribution of keys. This improves join performance by
+enabling the join optimizer to better choose in which order it should
+join the tables and which keys it should use:
+@code{myisamchk --describe --verbose table_name'} or using @code{SHOW KEYS} in
+@strong{MySQL}.
+@item -d or --description
+Prints some information about table.
+@item -A or --set-auto-increment[=value]
+Force auto_increment to start at this or higher value. If no value is
+given, then sets the next auto_increment value to the highest used value
+for the auto key + 1.
+@item -S or --sort-index
+Sort the index tree blocks in high-low order.
+This will optimize seeks and will make table scanning by key faster.
+@item -R or --sort-records=#
+Sorts records according to an index. This makes your data much more localized
+and may speed up ranged @code{SELECT} and @code{ORDER BY} operations on
+this index. (It may be VERY slow to do a sort the first time!)
+To find out a table's index numbers, use @code{SHOW INDEX}, which shows a
+table's indexes in the same order that @code{myisamchk} sees them. Indexes are
+numbered beginning with 1.
+@end table
+
+@node myisamchk memory, Crash recovery, myisamchk other options, Table maintenance
+@subsubsection @code{myisamchk} Memory Usage
+
+@cindex memory usage, myisamchk
+
+Memory allocation is important when you run @code{myisamchk}.
+@code{myisamchk} uses no more memory than you specify with the @code{-O}
+options. If you are going to use @code{myisamchk} on very large files,
+you should first decide how much memory you want it to use. The default
+is to use only about 3M to fix things. By using larger values, you can
+get @code{myisamchk} to operate faster. For example, if you have more
+than 32M RAM, you could use options such as these (in addition to any
+other options you might specify):
+
+@example
+shell> myisamchk -O sort=16M -O key=16M -O read=1M -O write=1M ...
+@end example
+
+Using @code{-O sort=16M} should probably be enough for most cases.
+
+Be aware that @code{myisamchk} uses temporary files in @code{TMPDIR}. If
+@code{TMPDIR} points to a memory file system, you may easily get out of
+memory errors. If this happens, set @code{TMPDIR} to point at some directory
+with more space and restart @code{myisamchk}.
+
+When repairing, @code{myisamchk} will also need a lot of disk space:
+
+@itemize @bullet
@item
-If you can't get your password to work, remember that you must use
-the @code{PASSWORD()} function if you set the password with the
-@code{INSERT}, @code{UPDATE}, or @code{SET PASSWORD} statements. The
-@code{PASSWORD()} function is unnecessary if you specify the password using
-the @code{GRANT ... INDENTIFIED BY} statement or the @code{mysqladmin
-password} command.
-@xref{Passwords}.
+Double the size of the record file (the original one and a copy). This
+space is not needed if one does a repair with @code{--quick}, as in this
+case only the index file will be re-created. This space is needed on the
+same disk as the original record file!
+@item
+Space for the new index file that replaces the old one. The old
+index file is truncated at start, so one usually ignore this space.
+This space is needed on the same disk as the original index file!
+@item
+When using @code{--recover} or @code{--sort-recover}
+(but not when using @code{--safe-recover}, you will need space for a
+sort buffer for:
+@code{(largest_key + row_pointer_length)*number_of_rows * 2}.
+You can check the length of the keys and the row_pointer_length with
+@code{myisamchk -dv table}.
+This space is allocated on the temporary disk (specified by @code{TMPDIR} or
+@code{--tmpdir=#}).
+@end itemize
+
+If you have a problem with disk space during repair, you can try to use
+@code{--safe-recover} instead of @code{--recover}.
+
+@node Crash recovery, Check, myisamchk memory, Table maintenance
+@subsubsection Using @code{myisamchk} for Crash Recovery
+
+@cindex crash, recovery
+@cindex recovery, from crash
+
+If you run @code{mysqld} with @code{--skip-locking} (which is the default on
+some systems, like Linux), you can't reliably use @code{myisamchk} to
+check a table when @code{mysqld} is using the same table. If you
+can be sure that no one is accessing the tables through @code{mysqld}
+while you run @code{myisamchk}, you only have to do @code{mysqladmin
+flush-tables} before you start checking the tables. If you can't
+guarantee the above, then you must take down @code{mysqld} while you
+check the tables. If you run @code{myisamchk} while @code{mysqld} is updating
+the tables, you may get a warning that a table is corrupt even if it
+isn't.
+
+If you are not using @code{--skip-locking}, you can use @code{myisamchk}
+to check tables at any time. While you do this, all clients that try
+to update the table will wait until @code{myisamchk} is ready before
+continuing.
+
+If you use @code{myisamchk} to repair or optimize tables, you
+@strong{MUST} always ensure that the @code{mysqld} server is not using
+the table (this also applies if you are using @code{--skip-locking}).
+If you don't take down @code{mysqld} you should at least do a
+@code{mysqladmin flush-tables} before you run @code{myisamchk}.
+
+This chapter describes how to check for and deal with data corruption
+in @strong{MySQL} databases. If your tables get corrupted a lot you should
+try to find the reason for this! @xref{Crashing}.
+
+The @code{MyISAM} table section contains reason for why a table could be
+corrupted. @xref{MyISAM table problems}.
+
+When performing crash recovery, it is important to understand that each table
+@code{tbl_name} in a database corresponds to three files in the database
+directory:
+
+@multitable @columnfractions .2 .8
+@item @strong{File} @tab @strong{Purpose}
+@item @file{tbl_name.frm} @tab Table definition (form) file
+@item @file{tbl_name.MYD} @tab Data file
+@item @file{tbl_name.MYI} @tab Index file
+@end multitable
+
+Each of these three file types is subject to corruption in various ways, but
+problems occur most often in data files and index files.
+
+@code{myisamchk} works by creating a copy of the @file{.MYD} (data) file
+row by row. It ends the repair stage by removing the old @file{.MYD}
+file and renaming the new file to the original file name. If you use
+@code{--quick}, @code{myisamchk} does not create a temporary @file{.MYD}
+file, but instead assumes that the @file{.MYD} file is correct and only
+generates a new index file without touching the @file{.MYD} file. This
+is safe, because @code{myisamchk} automatically detects if the
+@file{.MYD} file is corrupt and aborts the repair in this case. You can
+also give two @code{--quick} options to @code{myisamchk}. In this case,
+@code{myisamchk} does not abort on some errors (like duplicate key) but
+instead tries to resolve them by modifying the @file{.MYD}
+file. Normally the use of two @code{--quick} options is useful only if
+you have too little free disk space to perform a normal repair. In this
+case you should at least make a backup before running @code{myisamchk}.
+
+
+@node Check, Repair, Crash recovery, Table maintenance
+@subsubsection How to Check Tables for Errors
+
+@cindex checking, tables for errors
+@cindex tables, error checking
+@cindex errors, checking tables for
+
+To check a MyISAM table, use the following commands:
+
+@table @code
+@item myisamchk tbl_name
+This finds 99.99% of all errors. What it can't find is corruption that
+involves @strong{ONLY} the data file (which is very unusual). If you want
+to check a table, you should normally run @code{myisamchk} without options or
+with either the @code{-s} or @code{--silent} option.
+
+@item myisamchk -m tbl_name
+This finds 99.999% of all errors. It checks first all index entries for errors and
+then it reads through all rows. It calculates a checksum for all keys in
+the rows and verifies that they checksum matches the checksum for the keys
+in the index tree.
+
+@item myisamchk -e tbl_name
+This does a complete and thorough check of all data (@code{-e} means
+``extended check''). It does a check-read of every key for each row to verify
+that they indeed point to the correct row. This may take a LONG time on a
+big table with many keys. @code{myisamchk} will normally stop after the first
+error it finds. If you want to obtain more information, you can add the
+@code{--verbose} (@code{-v}) option. This causes @code{myisamchk} to keep
+going, up through a maximum of 20 errors. In normal usage, a simple
+@code{myisamchk} (with no arguments other than the table name) is sufficient.
+
+@item myisamchk -e -i tbl_name
+Like the previous command, but the @code{-i} option tells @code{myisamchk} to
+print some informational statistics, too.
+@end table
+
+
+@node Repair, Optimization, Check, Table maintenance
+@subsubsection How to Repair Tables
+
+@cindex tables, repairing
+@cindex repairing, tables
+
+In the following section we only talk about using @code{myisamchk} on
+@code{MyISAM} tables (extensions @code{.MYI} and @code{.MYD}). If you
+are using @code{ISAM} tables (extensions @code{.ISM} and @code{.ISD}),
+you should use @code{isamchk} instead.
+
+Starting with @strong{MySQL} Version 3.23.14, you can repair MyISAM
+tables with the @code{REPAIR TABLE} command. @xref{REPAIR TABLE}.
+
+The symptoms of a corrupted table include queries that abort unexpectedly
+and observable errors such as these:
+
+@itemize @bullet
@item
-@code{localhost} is a synonym for your local hostname, and is also the
-default host to which clients try to connect if you specify no host
-explicitly. However, connections to @code{localhost} do not work if you are
-running on a system that uses MIT-pthreads (@code{localhost} connections are
-made using Unix sockets, which are not supported by MIT-pthreads). To avoid
-this problem on such systems, you should use the @code{--host} option to name
-the server host explicitly. This will make a TCP/IP connection to the
-@code{mysqld} server. In this case, you must have your real hostname in
-@code{user} table entries on the server host. (This is true even if you are
-running a client program on the same host as the server.)
+@file{tbl_name.frm} is locked against change
+@item
+Can't find file @file{tbl_name.MYI} (Errcode: ###)
+@item
+Unexpected end of file
+@item
+Record file is crashed
+@item
+Got error ### from table handler
+
+To get more information about the error you can run @code{perror ###}. Here
+is the most common errors that indicates a problem with the table:
+@example
+shell> perror 126 127 132 134 135 136 141 144 145
+126 = Index file is crashed / Wrong file format
+127 = Record-file is crashed
+132 = Old database file
+134 = Record was already deleted (or record file crashed)
+135 = No more room in record file
+136 = No more room in index file
+141 = Duplicate unique key or constraint on write or update
+144 = Table is crashed and last repair failed
+145 = Table was marked as crashed and should be repaired
+@end example
+
+Note that error 135, no more room in record file, is not an error that
+can be fixed by a simple repair. In this case you have to do:
+
+@example
+ALTER TABLE table MAX_ROWS=xxx AVG_ROW_LENGTH=yyy;
+@end example
+
+@end itemize
+
+In the other cases, you must repair your tables. @code{myisamchk}
+can usually detect and fix most things that go wrong.
+
+The repair process involves up to four stages, described below. Before you
+begin, you should @code{cd} to the database directory and check the
+permissions of the table files. Make sure they are readable by the Unix user
+that @code{mysqld} runs as (and to you, because you need to access the files
+you are checking). If it turns out you need to modify files, they must also
+be writable by you.
+
+If you are using @strong{MySQL} Version 3.23.16 and above, you can (and
+should) use the @code{CHECK} and @code{REPAIR} commands to check and repair
+@code{MyISAM} tables. @xref{CHECK TABLE}. @xref{REPAIR TABLE}.
+
+The manual section about table maintenance includes the options to
+@code{isamchk}/@code{myisamchk}. @xref{Table maintenance}.
+
+The following section is for the cases where the above command fails or
+if you want to use the extended features that @code{isamchk}/@code{myisamchk} provides.
+
+If you are going to repair a table from the command line, you must first
+take down the @code{mysqld} server. Note that when you do
+@code{mysqladmin shutdown} on a remote server, the @code{mysqld} server
+will still be alive for a while after @code{mysqladmin} returns, until
+all queries are stopped and all keys have been flushed to disk.
+
+@noindent
+@strong{Stage 1: Checking your tables}
+
+Run @code{myisamchk *.MYI} or @code{myisamchk -e *.MYI} if you have
+more time. Use the @code{-s} (silent) option to suppress unnecessary
+information.
+
+If the @code{mysqld} server is done you should use the --update option to tell
+@code{myisamchk} to mark the table as 'checked'.
+
+You have to repair only those tables for which @code{myisamchk} announces an
+error. For such tables, proceed to Stage 2.
+
+If you get weird errors when checking (such as @code{out of
+memory} errors), or if @code{myisamchk} crashes, go to Stage 3.
+
+@noindent
+@strong{Stage 2: Easy safe repair}
+
+NOTE: If you want repairing to go much faster, you should add: @code{-O
+sort_buffer=# -O key_buffer=#} (where # is about 1/4 of the available
+memory) to all @code{isamchk/myisamchk} commands.
+
+First, try @code{myisamchk -r -q tbl_name} (@code{-r -q} means ``quick
+recovery mode''). This will attempt to repair the index file without
+touching the data file. If the data file contains everything that it
+should and the delete links point at the correct locations within the
+data file, this should work, and the table is fixed. Start repairing the
+next table. Otherwise, use the following procedure:
+
+@enumerate
@item
-If you get an @code{Access denied} error when trying to connect to the
-database with @code{mysql -u user_name db_name}, you may have a problem
-with the @code{user} table. Check this by executing @code{mysql -u root
-mysql} and issuing this SQL statement:
+Make a backup of the data file before continuing.
+
+@item
+Use @code{myisamchk -r tbl_name} (@code{-r} means ``recovery mode''). This will
+remove incorrect records and deleted records from the data file and
+reconstruct the index file.
+
+@item
+If the preceding step fails, use @code{myisamchk --safe-recover tbl_name}.
+Safe recovery mode uses an old recovery method that handles a few cases that
+regular recovery mode doesn't (but is slower).
+@end enumerate
+
+If you get weird errors when repairing (such as @code{out of
+memory} errors), or if @code{myisamchk} crashes, go to Stage 3.
+
+@noindent
+@strong{Stage 3: Difficult repair}
+
+You should only reach this stage if the first 16K block in the index file is
+destroyed or contains incorrect information, or if the index file is
+missing. In this case, it's necessary to create a new index file. Do so as
+follows:
+
+@enumerate
+@item
+Move the data file to some safe place.
+
+@item
+Use the table description file to create new (empty) data and index files:
@example
-mysql> SELECT * FROM user;
+shell> mysql db_name
+mysql> SET AUTOCOMMIT=1;
+mysql> TRUNCATE TABLE table_name;
+mysql> quit
@end example
-The result should include an entry with the @code{Host} and @code{User}
-columns matching your computer's hostname and your @strong{MySQL} user name.
+If your SQL version doesn't have @code{TRUNCATE TABLE}, use @code{DELETE FROM
+table_name} instead.
@item
-The @code{Access denied} error message will tell you who you are trying
-to log in as, the host from which you are trying to connect, and whether
-or not you were using a password. Normally, you should have one entry in
-the @code{user} table that exactly matches the hostname and user name
-that were given in the error message. For example if you get an error
-message that contains @code{Using password: NO}, this means that you
-tried to login without an password.
+Copy the old data file back onto the newly created data file.
+(Don't just move the old file back onto the new file; you want to retain
+a copy in case something goes wrong.)
+@end enumerate
+Go back to Stage 2. @code{myisamchk -r -q} should work now. (This shouldn't
+be an endless loop.)
+
+@noindent
+@strong{Stage 4: Very difficult repair}
+
+You should reach this stage only if the description file has also
+crashed. That should never happen, because the description file isn't changed
+after the table is created:
+
+@enumerate
@item
-If you get the following error when you try to connect from a different host
-than the one on which the @strong{MySQL} server is running, then there is no
-row in the @code{user} table that matches that host:
+Restore the description file from a backup and go back to Stage 3. You can
+also restore the index file and go back to Stage 2. In the latter case, you
+should start with @code{myisamchk -r}.
+
+@item
+If you don't have a backup but know exactly how the table was created, create
+a copy of the table in another database. Remove the new data file, then move
+the description and index files from the other database to your crashed
+database. This gives you new description and index files, but leaves
+the data file alone. Go back to Stage 2 and attempt to reconstruct
+the index file.
+@end enumerate
+
+
+@node Optimization, , Repair, Table maintenance
+@subsubsection Table Optimization
+
+@cindex tables, optimizing
+@cindex optimizing, tables
+
+To coalesce fragmented records and eliminate wasted space resulting from
+deleting or updating records, run @code{myisamchk} in recovery mode:
@example
-Host ... is not allowed to connect to this MySQL server
+shell> myisamchk -r tbl_name
@end example
-You can fix this by using the command-line tool @code{mysql} (on the
-server host!) to add a row to the @code{user}, @code{db}, or @code{host}
-table for the user/hostname combination from which you are trying to
-connect and then execute @code{mysqladmin flush-privileges}. If you are
-not running @strong{MySQL} Version 3.22 and you don't know the IP number or
-hostname of the machine from which you are connecting, you should put an
-entry with @code{'%'} as the @code{Host} column value in the @code{user}
-table and restart @code{mysqld} with the @code{--log} option on the
-server machine. After trying to connect from the client machine, the
-information in the @strong{MySQL} log will indicate how you really did
-connect. (Then replace the @code{'%'} in the @code{user} table entry
-with the actual hostname that shows up in the log. Otherwise, you'll
-have a system that is insecure.)
+You can optimize a table in the same way using the SQL @code{OPTIMIZE TABLE}
+statement. @code{OPTIMIZE TABLE} does a repair of the table, a key
+analyzes and also sorts the index tree to give faster key lookups.
+There is also no possibility of unwanted interaction between a utility
+and the server, because the server does all the work when you use
+@code{OPTIMIZE TABLE}. @xref{OPTIMIZE TABLE}.
-Another reason for this error on Linux is that you are using a binary
-@strong{MySQL} version that is compiled with a different glibc version
-than the one you are using. In this case you should either upgrade your
-OS/glibc or download the source @strong{MySQL} version and compile this
-yourself. A source RPM is normally trivial to compile and install, so
-this isn't a big problem.
+@code{myisamchk} also has a number of other options you can use to improve
+the performance of a table:
+
+@table @code
+@item -S, --sort-index
+@item -R index_num, --sort-records=index_num
+@item -a, --analyze
+@end table
+
+For a full description of the option. @xref{myisamchk syntax}.
+
+
+@node Maintenance regimen, Table-info, Table maintenance, Disaster Prevention
+@subsection Setting Up a Table Maintenance Regimen
+
+@cindex maintaining, tables
+@cindex tables, maintenance regimen
+
+Starting with @strong{MySQL} Version 3.23.13, you can check MyISAM
+tables with the @code{CHECK TABLE} command. @xref{CHECK TABLE}. You can
+repair tables with the @code{REPAIR TABLE} command. @xref{REPAIR TABLE}.
+
+It is a good idea to perform table checks on a regular basis rather than
+waiting for problems to occur. For maintenance purposes, you can use
+@code{myisamchk -s} to check tables. The @code{-s} option (short for
+@code{--silent}) causes @code{myisamchk} to run in silent mode, printing
+messages only when errors occur.
+
+@tindex .pid (process ID) file
+It's also a good idea to check tables when the server starts up.
+For example, whenever the machine has done a reboot in the middle of an
+update, you usually need to check all the tables that could have been
+affected. (This is an ``expected crashed table''.) You could add a test to
+@code{safe_mysqld} that runs @code{myisamchk} to check all tables that have
+been modified during the last 24 hours if there is an old @file{.pid}
+(process ID) file left after a reboot. (The @file{.pid} file is created by
+@code{mysqld} when it starts up and removed when it terminates normally. The
+presence of a @file{.pid} file at system startup time indicates that
+@code{mysqld} terminated abnormally.)
+
+An even better test would be to check any table whose last-modified time
+is more recent than that of the @file{.pid} file.
+
+You should also check your tables regularly during normal system
+operation. At @strong{MySQL AB}, we run a @code{cron} job to check all
+our important tables once a week, using a line like this in a @file{crontab}
+file:
+
+@example
+35 0 * * 0 /path/to/myisamchk --fast --silent /path/to/datadir/*/*.MYI
+@end example
+
+This prints out information about crashed tables so we can examine and repair
+them when needed.
+
+As we haven't had any unexpectedly crashed tables (tables that become
+corrupted for reasons other than hardware trouble)
+for a couple of years now (this is really true), once a week is
+more than enough for us.
+
+We recommend that to start with, you execute @code{myisamchk -s} each
+night on all tables that have been updated during the last 24 hours,
+until you come to trust @strong{MySQL} as much as we do.
+
+@cindex tables, defragment
+Normally you don't need to maintain @strong{MySQL} tables that much. If
+you are changing tables with dynamic size rows (tables with @code{VARCHAR},
+@code{BLOB} or @code{TEXT} columns) or have tables with many deleted rows
+you may want to from time to time (once a month?) defragment/reclaim space
+from the tables.
+
+You can do this by using @code{OPTIMIZE TABLE} on the tables in question or
+if you can take the @code{mysqld} server down for a while do:
+
+@example
+isamchk -r --silent --sort-index -O sort_buffer_size=16M */*.ISM
+myisamchk -r --silent --sort-index -O sort_buffer_size=16M */*.MYI
+@end example
+
+
+@node Table-info, , Maintenance regimen, Disaster Prevention
+@subsection Getting Information About a Table
+
+@cindex tables, information
+
+To get a description of a table or statistics about it, use the commands shown
+below. We explain some of the information in more detail later:
+
+@table @code
+@item myisamchk -d tbl_name
+Runs @code{myisamchk} in ``describe mode'' to produce a description of
+your table. If you start the @strong{MySQL} server using the
+@code{--skip-locking} option, @code{myisamchk} may report an error for a
+table that is updated while it runs. However, because @code{myisamchk}
+doesn't change the table in describe mode, there isn't any risk of
+destroying data.
+
+@item myisamchk -d -v tbl_name
+To produce more information about what @code{myisamchk} is doing, add @code{-v}
+to tell it to run in verbose mode.
+
+@item myisamchk -eis tbl_name
+Shows only the most important information from a table. It is slow because it
+must read the whole table.
+
+@item myisamchk -eiv tbl_name
+This is like @code{-eis}, but tells you what is being done.
+@end table
+
+@cindex examples, @code{myisamchk} output
+@cindex @code{myisamchk}, example output
+Example of @code{myisamchk -d} output:
+@example
+MyISAM file: company.MYI
+Record format: Fixed length
+Data records: 1403698 Deleted blocks: 0
+Recordlength: 226
+
+table description:
+Key Start Len Index Type
+1 2 8 unique double
+2 15 10 multip. text packed stripped
+3 219 8 multip. double
+4 63 10 multip. text packed stripped
+5 167 2 multip. unsigned short
+6 177 4 multip. unsigned long
+7 155 4 multip. text
+8 138 4 multip. unsigned long
+9 177 4 multip. unsigned long
+ 193 1 text
+@end example
+
+Example of @code{myisamchk -d -v} output:
+@example
+MyISAM file: company
+Record format: Fixed length
+File-version: 1
+Creation time: 1999-10-30 12:12:51
+Recover time: 1999-10-31 19:13:01
+Status: checked
+Data records: 1403698 Deleted blocks: 0
+Datafile parts: 1403698 Deleted data: 0
+Datafilepointer (bytes): 3 Keyfile pointer (bytes): 3
+Max datafile length: 3791650815 Max keyfile length: 4294967294
+Recordlength: 226
+
+table description:
+Key Start Len Index Type Rec/key Root Blocksize
+1 2 8 unique double 1 15845376 1024
+2 15 10 multip. text packed stripped 2 25062400 1024
+3 219 8 multip. double 73 40907776 1024
+4 63 10 multip. text packed stripped 5 48097280 1024
+5 167 2 multip. unsigned short 4840 55200768 1024
+6 177 4 multip. unsigned long 1346 65145856 1024
+7 155 4 multip. text 4995 75090944 1024
+8 138 4 multip. unsigned long 87 85036032 1024
+9 177 4 multip. unsigned long 178 96481280 1024
+ 193 1 text
+@end example
+
+Example of @code{myisamchk -eis} output:
+@example
+Checking MyISAM file: company
+Key: 1: Keyblocks used: 97% Packed: 0% Max levels: 4
+Key: 2: Keyblocks used: 98% Packed: 50% Max levels: 4
+Key: 3: Keyblocks used: 97% Packed: 0% Max levels: 4
+Key: 4: Keyblocks used: 99% Packed: 60% Max levels: 3
+Key: 5: Keyblocks used: 99% Packed: 0% Max levels: 3
+Key: 6: Keyblocks used: 99% Packed: 0% Max levels: 3
+Key: 7: Keyblocks used: 99% Packed: 0% Max levels: 3
+Key: 8: Keyblocks used: 99% Packed: 0% Max levels: 3
+Key: 9: Keyblocks used: 98% Packed: 0% Max levels: 4
+Total: Keyblocks used: 98% Packed: 17%
+
+Records: 1403698 M.recordlength: 226 Packed: 0%
+Recordspace used: 100% Empty space: 0% Blocks/Record: 1.00
+Record blocks: 1403698 Delete blocks: 0
+Recorddata: 317235748 Deleted data: 0
+Lost space: 0 Linkdata: 0
+
+User time 1626.51, System time 232.36
+Maximum resident set size 0, Integral resident set size 0
+Non physical pagefaults 0, Physical pagefaults 627, Swaps 0
+Blocks in 0 out 0, Messages in 0 out 0, Signals 0
+Voluntary context switches 639, Involuntary context switches 28966
+@end example
+
+Example of @code{myisamchk -eiv} output:
+@example
+Checking MyISAM file: company
+Data records: 1403698 Deleted blocks: 0
+- check file-size
+- check delete-chain
+block_size 1024:
+index 1:
+index 2:
+index 3:
+index 4:
+index 5:
+index 6:
+index 7:
+index 8:
+index 9:
+No recordlinks
+- check index reference
+- check data record references index: 1
+Key: 1: Keyblocks used: 97% Packed: 0% Max levels: 4
+- check data record references index: 2
+Key: 2: Keyblocks used: 98% Packed: 50% Max levels: 4
+- check data record references index: 3
+Key: 3: Keyblocks used: 97% Packed: 0% Max levels: 4
+- check data record references index: 4
+Key: 4: Keyblocks used: 99% Packed: 60% Max levels: 3
+- check data record references index: 5
+Key: 5: Keyblocks used: 99% Packed: 0% Max levels: 3
+- check data record references index: 6
+Key: 6: Keyblocks used: 99% Packed: 0% Max levels: 3
+- check data record references index: 7
+Key: 7: Keyblocks used: 99% Packed: 0% Max levels: 3
+- check data record references index: 8
+Key: 8: Keyblocks used: 99% Packed: 0% Max levels: 3
+- check data record references index: 9
+Key: 9: Keyblocks used: 98% Packed: 0% Max levels: 4
+Total: Keyblocks used: 9% Packed: 17%
+
+- check records and index references
+[LOTS OF ROW NUMBERS DELETED]
+
+Records: 1403698 M.recordlength: 226 Packed: 0%
+Recordspace used: 100% Empty space: 0% Blocks/Record: 1.00
+Record blocks: 1403698 Delete blocks: 0
+Recorddata: 317235748 Deleted data: 0
+Lost space: 0 Linkdata: 0
+
+User time 1639.63, System time 251.61
+Maximum resident set size 0, Integral resident set size 0
+Non physical pagefaults 0, Physical pagefaults 10580, Swaps 0
+Blocks in 4 out 0, Messages in 0 out 0, Signals 0
+Voluntary context switches 10604, Involuntary context switches 122798
+@end example
+
+Here are the sizes of the data and index files for the table used in the
+preceding examples:
+
+@example
+-rw-rw-r-- 1 monty tcx 317235748 Jan 12 17:30 company.MYD
+-rw-rw-r-- 1 davida tcx 96482304 Jan 12 18:35 company.MYM
+@end example
+
+Explanations for the types of information @code{myisamchk} produces are
+given below. The ``keyfile'' is the index file. ``Record'' and ``row''
+are synonymous:
+
+@table @code
+@item ISAM file
+Name of the ISAM (index) file.
+
+@item Isam-version
+Version of ISAM format. Currently always 2.
+
+@item Creation time
+When the data file was created.
+
+@item Recover time
+When the index/data file was last reconstructed.
+
+@item Data records
+How many records are in the table.
+
+@item Deleted blocks
+How many deleted blocks still have reserved space.
+You can optimize your table to minimize this space.
+@xref{Optimization}.
+
+@item Datafile: Parts
+For dynamic record format, this indicates how many data blocks there are. For
+an optimized table without fragmented records, this is the same as @code{Data
+records}.
+
+@item Deleted data
+How many bytes of non-reclaimed deleted data there are.
+You can optimize your table to minimize this space.
+@xref{Optimization}.
+
+@item Datafile pointer
+The size of the data file pointer, in bytes. It is usually 2, 3, 4, or 5
+bytes. Most tables manage with 2 bytes, but this cannot be controlled
+from @strong{MySQL} yet. For fixed tables, this is a record address. For
+dynamic tables, this is a byte address.
+
+@item Keyfile pointer
+The size of the index file pointer, in bytes. It is usually 1, 2, or 3
+bytes. Most tables manage with 2 bytes, but this is calculated
+automatically by @strong{MySQL}. It is always a block address.
+
+@item Max datafile length
+How long the table's data file (@code{.MYD} file) can become, in bytes.
+
+@item Max keyfile length
+How long the table's key file (@code{.MYI} file) can become, in bytes.
+
+@item Recordlength
+How much space each record takes, in bytes.
+
+@item Record format
+The format used to store table rows.
+The examples shown above use @code{Fixed length}.
+Other possible values are @code{Compressed} and @code{Packed}.
+
+@item table description
+A list of all keys in the table. For each key, some low-level information
+is presented:
+
+@table @code
+@item Key
+This key's number.
+
+@item Start
+Where in the record this index part starts.
+
+@item Len
+How long this index part is. For packed numbers, this should always be
+the full length of the column. For strings, it may be shorter than the full
+length of the indexed column, because you can index a prefix of a string
+column.
+
+@item Index
+@code{unique} or @code{multip.} (multiple). Indicates whether or not one value
+can exist multiple times in this index.
+
+@item Type
+What data-type this index part has. This is an ISAM data-type
+with the options @code{packed}, @code{stripped} or @code{empty}.
+
+@item Root
+Address of the root index block.
+
+@item Blocksize
+The size of each index block. By default this is 1024, but the value may be
+changed at compile time.
+
+@item Rec/key
+This is a statistical value used by the optimizer. It tells how many
+records there are per value for this key. A unique key always has a
+value of 1. This may be updated after a table is loaded (or greatly
+changed) with @code{myisamchk -a}. If this is not updated at all, a default
+value of 30 is given.
+@end table
@item
-If you get an error message where the hostname is not shown or where the
-hostname is an IP, even if you try to connect with a hostname:
+In the first example above, the 9th key is a multi-part key with two parts.
+
+@item Keyblocks used
+What percentage of the keyblocks are used. Because the table used in the
+examples had just been reorganized with @code{myisamchk}, the values are very
+high (very near the theoretical maximum).
+
+@item Packed
+@strong{MySQL} tries to pack keys with a common suffix. This can only be used
+for @code{CHAR}/@code{VARCHAR}/@code{DECIMAL} keys. For long strings like
+names, this can significantly reduce the space used. In the third example
+above, the 4th key is 10 characters long and a 60% reduction in space is
+achieved.
+
+@item Max levels
+How deep the B-tree for this key is. Large tables with long keys get high
+values.
+
+@item Records
+How many rows are in the table.
+
+@item M.recordlength
+The average record length. For tables with fixed-length records, this is the
+exact record length.
+
+@item Packed
+@strong{MySQL} strips spaces from the end of strings. The @code{Packed}
+value indicates the percentage of savings achieved by doing this.
+
+@item Recordspace used
+What percentage of the data file is used.
+
+@item Empty space
+What percentage of the data file is unused.
+
+@item Blocks/Record
+Average number of blocks per record (that is, how many links a fragmented
+record is composed of). This is always 1 for fixed-format tables. This value
+should stay as close to 1.0 as possible. If it gets too big, you can
+reorganize the table with @code{myisamchk}.
+@xref{Optimization}.
+
+@item Recordblocks
+How many blocks (links) are used. For fixed format, this is the same as the number
+of records.
+
+@item Deleteblocks
+How many blocks (links) are deleted.
+
+@item Recorddata
+How many bytes in the data file are used.
+
+@item Deleted data
+How many bytes in the data file are deleted (unused).
+
+@item Lost space
+If a record is updated to a shorter length, some space is lost. This is
+the sum of all such losses, in bytes.
+
+@item Linkdata
+When the dynamic table format is used, record fragments are linked with
+pointers (4 to 7 bytes each). @code{Linkdata} is the sum of the amount of
+storage used by all such pointers.
+@end table
+
+If a table has been compressed with @code{myisampack}, @code{myisamchk
+-d} prints additional information about each table column. See
+@ref{myisampack, , @code{myisampack}}, for an example of this
+information and a description of what it means.
+
+
+@node Database Administration, KILL, Disaster Prevention, MySQL Database Administration
+@section Database Administration Language Reference
+
+
+@menu
+* OPTIMIZE TABLE::
+* ANALYZE TABLE::
+* FLUSH::
+@end menu
+
+@node OPTIMIZE TABLE, ANALYZE TABLE, Database Administration, Database Administration
+@subsection @code{OPTIMIZE TABLE} Syntax
+
+@findex OPTIMIZE TABLE
+
+@cindex tables, defragmenting
+@cindex tables, fragmentation
@example
-shell> mysqladmin -u root -pxxxx -h some-hostname ver
-Access denied for user: 'root@' (Using password: YES)
+OPTIMIZE TABLE tbl_name[,tbl_name]...
@end example
-This means that @strong{MySQL} got some error when trying to resolve the
-IP to a hostname. In this case you can execute @code{mysqladmin
-flush-hosts} to reset the internal DNS cache. @xref{DNS}.
+@code{OPTIMIZE TABLE} should be used if you have deleted a large part of a
+table or if you have made many changes to a table with variable-length rows
+(tables that have @code{VARCHAR}, @code{BLOB}, or @code{TEXT} columns).
+Deleted records are maintained in a linked list and subsequent @code{INSERT}
+operations reuse old record positions. You can use @code{OPTIMIZE TABLE} to
+reclaim the unused space and to defragment the data file.
-Some permanent solutions are:
+For the moment @code{OPTIMIZE TABLE} only works on @strong{MyISAM} and
+@code{BDB} tables. For @code{BDB} tables, @code{OPTIMIZE TABLE} is
+currently mapped to @code{ANALYZE TABLE}. @xref{ANALYZE TABLE}.
-@itemize @minus
+You can get optimize table to work on other table types by starting
+@code{mysqld} with @code{--skip-new} or @code{--safe-mode}, but in this
+case @code{OPTIMIZE TABLE} is just mapped to @code{ALTER TABLE}.
+
+@code{OPTIMIZE TABLE} works the following way:
+@itemize @bullet
@item
-Try to find out what is wrong with your DNS server and fix this.
+If the table has deleted or split rows, repair the table.
@item
-Specify IPs instead of hostnames in the @strong{MySQL} privilege tables.
+If the index pages are not sorted, sort them.
@item
-Start @code{mysqld} with @code{--skip-name-resolve}.
+If the statistics are not up to date (and the repair couldn't be done
+by sorting the index), update them.
+@end itemize
+
+@code{OPTIMIZE TABLE} for @code{MyISAM} tables is equvialent of running
+@code{myisamchk --quick --check-changed-tables --sort-index --analyze}
+on the table.
+
+Note that the table is locked during the time @code{OPTIMIZE TABLE} is
+running!
+
+
+@node ANALYZE TABLE, FLUSH, OPTIMIZE TABLE, Database Administration
+@subsection @code{ANALYZE TABLE} Syntax
+
+@findex ANALYZE TABLE
+
+@example
+ANALYZE TABLE tbl_name[,tbl_name...]
+@end example
+
+Analyze and store the key distribution for the table. During the
+analyze the table is locked with a read lock. This works on
+@code{MyISAM} and @code{BDB} tables.
+
+This is equivalent to running @code{myisamchk -a} on the table.
+
+@strong{MySQL} uses the stored key distribution to decide in which order
+tables should be joined when one does a join on something else than a
+constant.
+
+The command returns a table with the following columns:
+
+@multitable @columnfractions .35 .65
+@item @strong{Column} @tab @strong{Value}
+@item Table @tab Table name
+@item Op @tab Always ``analyze''
+@item Msg_type @tab One of @code{status}, @code{error}, @code{info} or @code{warning}.
+@item Msg_text @tab The message.
+@end multitable
+
+You can check the stored key distribution with the @code{SHOW INDEX} command.
+@xref{SHOW DATABASE INFO}.
+
+If the table hasn't changed since the last @code{ANALYZE TABLE} command,
+the table will not be analyzed again.
+
+
+@node FLUSH, , ANALYZE TABLE, Database Administration
+@subsection @code{FLUSH} Syntax
+
+@findex FLUSH
+
+@cindex @code{mysqladmin}
+@cindex clearing, caches
+@cindex caches, clearing
+
+@example
+FLUSH flush_option [,flush_option]
+@end example
+
+You should use the @code{FLUSH} command if you want to clear some of the
+internal caches @strong{MySQL} uses. To execute @code{FLUSH}, you must have
+the @strong{RELOAD} privilege.
+
+@code{flush_option} can be any of the following:
+
+@multitable @columnfractions .15 .85
+@item @code{HOSTS} @tab Empties the host cache tables. You should flush the
+host tables if some of your hosts change IP number or if you get the
+error message @code{Host ... is blocked}. When more than
+@code{max_connect_errors} errors occur in a row for a given host while
+connection to the @strong{MySQL} server, @strong{MySQL} assumes
+something is wrong and blocks the host from further connection requests.
+Flushing the host tables allows the host to attempt to connect
+again. @xref{Blocked host}.) You can start @code{mysqld} with
+@code{-O max_connection_errors=999999999} to avoid this error message.
+
+@item @code{LOGS} @tab Closes and reopens all log files.
+If you have specified the update log file or a binary log file without
+an extension, the extension number of the log file will be incremented
+by one relative to the previous file. If you have used an extension in
+the file name, @strong{MySQL} will close and reopen the update log file.
+@xref{Update log}. This is the same thing as sending the @code{SIGHUP}
+signal to the @code{mysqld} server.
+
+@item @code{PRIVILEGES} @tab Reloads the privileges from the grant tables in
+the @code{mysql} database.
+
+@item @code{TABLES} @tab Closes all open tables and force all tables in use to be closed.
+
+@item @code{[TABLE | TABLES] table_name [,table_name...]} @tab Flushes only the given tables.
+
+@item @code{TABLES WITH READ LOCK} @tab Closes all open tables and locks all tables for all databases with a read until one executes @code{UNLOCK TABLES}. This is very convenient way to get backups if you have a file system, like Veritas,that can take snapshots in time.
+
+@item @code{STATUS} @tab Resets most status variables to zero. This is something one should only use when debugging a query.
+@end multitable
+
+You can also access each of the commands shown above with the @code{mysqladmin}
+utility, using the @code{flush-hosts}, @code{flush-logs}, @code{reload},
+or @code{flush-tables} commands.
+
+Take also a look at the @code{RESET} command used with
+replication. @xref{Replication SQL}.
+
+
+
+@node KILL, Localization, Database Administration, MySQL Database Administration
+@section @code{KILL} Syntax
+
+@findex KILL
+
+@cindex @code{mysqladmin}
+
+@example
+KILL thread_id
+@end example
+
+Each connection to @code{mysqld} runs in a separate thread. You can see
+which threads are running with the @code{SHOW PROCESSLIST} command and kill
+a thread with the @code{KILL thread_id} command.
+
+If you have the @strong{process} privilege, you can see and kill all threads.
+Otherwise, you can see and kill only your own threads.
+
+You can also use the @code{mysqladmin processlist} and @code{mysqladmin kill}
+commands to examine and kill threads.
+
+When you do a @code{KILL}, a thread specific @code{kill flag} is set for
+the thread.
+
+In most cases it may take some time for the thread to die as the kill
+flag is only checked at specific intervals.
+
+@itemize @bullet
@item
-Start @code{mysqld} with @code{--skip-host-cache}.
+In @code{SELECT}, @code{ORDER BY} and @code{GROUP BY} loops, the flag is
+checked after reading a block of rows. If the kill flag is set the
+statement is aborted
@item
-Connect to @code{localhost} if you are running the server and the client
-on the same machine.
+When doing an @code{ALTER TABLE} the kill flag is checked before each block of
+rows are read from the original table. If the kill flag was set the command
+is aborted and the temporary table is deleted.
@item
-Put the client machine names in @code{/etc/hosts}.
+When doing an @code{UPDATE TABLE} and @code{DELETE TABLE}, the kill flag
+is checked after each block read and after each updated or delete
+row. If the kill flag is set the statement is aborted. Note that if you
+are not using transactions, the changes will not be rolled back!
+@item
+@code{GET_LOCK()} will abort with @code{NULL}.
+@item
+An @code{INSERT DELAYED} thread will quickly flush all rows it has in
+memory and die.
+@item
+If the thread is in the table lock handler (state: @code{Locked}),
+the table lock will be quickly aborted.
+@item
+If the thread is waiting for free disk space in a @code{write} call, the
+write is aborted with an disk full error message.
+@end itemize
+
+
+@menu
+* SHOW::
+@end menu
+
+@node SHOW, , KILL, KILL
+@subsection @code{SHOW} Syntax
+
+@c FIX more index hits needed
+
+@findex SHOW DATABASE INFO
+@findex SHOW DATABASES
+@findex SHOW TABLES
+@findex SHOW COLUMNS
+@findex SHOW FIELDS
+@findex SHOW INDEX
+@findex SHOW KEYS
+@findex SHOW STATUS
+@findex SHOW VARIABLES
+@findex SHOW PROCESSLIST
+@findex SHOW TABLE STATUS
+@findex SHOW GRANTS
+@findex SHOW CREATE TABLE
+@findex SHOW MASTER STATUS
+@findex SHOW MASTER LOGS
+@findex SHOW SLAVE STATUS
+
+@example
+ SHOW DATABASES [LIKE wild]
+or SHOW [OPEN] TABLES [FROM db_name] [LIKE wild]
+or SHOW [FULL] COLUMNS FROM tbl_name [FROM db_name] [LIKE wild]
+or SHOW INDEX FROM tbl_name [FROM db_name]
+or SHOW TABLE STATUS [FROM db_name] [LIKE wild]
+or SHOW STATUS [LIKE wild]
+or SHOW VARIABLES [LIKE wild]
+or SHOW LOGS
+or SHOW [FULL] PROCESSLIST
+or SHOW GRANTS FOR user
+or SHOW CREATE TABLE table_name
+or SHOW MASTER STATUS
+or SHOW MASTER LOGS
+or SHOW SLAVE STATUS
+@end example
+
+@code{SHOW} provides information about databases, tables, columns, or
+status information about the server. If the @code{LIKE wild} part is
+used, the @code{wild} string can be a string that uses the SQL @samp{%}
+and @samp{_} wild-card characters.
+
+@menu
+* SHOW DATABASE INFO::
+* SHOW TABLE STATUS::
+* SHOW STATUS::
+* SHOW VARIABLES::
+* SHOW LOGS::
+* SHOW PROCESSLIST::
+* SHOW GRANTS::
+* SHOW CREATE TABLE::
+@end menu
+
+
+@node SHOW DATABASE INFO, SHOW TABLE STATUS, SHOW, SHOW
+@subsubsection Retrieving information about Database, Tables, Columns, and Indexes
+
+@cindex displaying, information, @code{SHOW}
+
+You can use @code{db_name.tbl_name} as an alternative to the @code{tbl_name
+FROM db_name} syntax. These two statements are equivalent:
+
+@example
+mysql> SHOW INDEX FROM mytable FROM mydb;
+mysql> SHOW INDEX FROM mydb.mytable;
+@end example
+
+@code{SHOW DATABASES} lists the databases on the @strong{MySQL} server
+host. You can also get this list using the @code{mysqlshow} command.
+
+@code{SHOW TABLES} lists the tables in a given database. You can also
+get this list using the @code{mysqlshow db_name} command.
+
+@strong{NOTE:} If a user doesn't have any privileges for a table, the table
+will not show up in the output from @code{SHOW TABLES} or @code{mysqlshow
+db_name}.
+
+@code{SHOW OPEN TABLES} lists the tables that are currently open in
+the table cache. @xref{Table cache}. The @code{Comment} field tells
+how many times the table is @code{cached} and @code{in_use}.
+
+@code{SHOW COLUMNS} lists the columns in a given table. If you specify
+the @code{FULL} option, you will also get the privileges you have for
+each column. If the column types are different than you expect them to
+be based on a @code{CREATE TABLE} statement, note that @strong{MySQL}
+sometimes changes column types. @xref{Silent column changes}.
+
+The @code{DESCRIBE} statement provides information similar to
+@code{SHOW COLUMNS}.
+@xref{DESCRIBE, , @code{DESCRIBE}}.
+
+@code{SHOW FIELDS} is a synonym for @code{SHOW COLUMNS}, and
+@code{SHOW KEYS} is a synonym for @code{SHOW INDEX}. You can also
+list a table's columns or indexes with @code{mysqlshow db_name tbl_name}
+or @code{mysqlshow -k db_name tbl_name}.
+
+@code{SHOW INDEX} returns the index information in a format that closely
+resembles the @code{SQLStatistics} call in ODBC. The following columns
+are returned:
+
+@multitable @columnfractions .35 .65
+@item @strong{Column} @tab @strong{Meaning}
+@item @code{Table} @tab Name of the table.
+@item @code{Non_unique} @tab 0 if the index can't contain duplicates.
+@item @code{Key_name} @tab Name of the index.
+@item @code{Seq_in_index} @tab Column sequence number in index,
+ starting with 1.
+@item @code{Column_name} @tab Column name.
+@item @code{Collation} @tab How the column is sorted in the index.
+ In @strong{MySQL}, this can have values
+ @samp{A} (Ascending) or @code{NULL} (Not
+ sorted).
+@item @code{Cardinality} @tab Number of unique values in the index.
+ This is updated by running
+ @code{isamchk -a}.
+@item @code{Sub_part} @tab Number of indexed characters if the
+ column is only partly indexed.
+ @code{NULL} if the entire key is indexed.
+@item @code{Comment} @tab Various remarks. For now, it tells
+ whether index is FULLTEXT or not.
+@end multitable
+
+Note that as the @code{Cardinality} is counted based on statistics
+stored as integers, it's not necessarily accurate for small tables.
+
+
+@node SHOW TABLE STATUS, SHOW STATUS, SHOW DATABASE INFO, SHOW
+@subsubsection @code{SHOW TABLE STATUS}
+
+@cindex displaying, table status
+@cindex tables, displaying status
+@cindex status, tables
+
+@example
+SHOW TABLE STATUS [FROM db_name] [LIKE wild]
+@end example
+
+@code{SHOW TABLE STATUS} (new in Version 3.23) works likes @code{SHOW
+STATUS}, but provides a lot of information about each table. You can
+also get this list using the @code{mysqlshow --status db_name} command.
+The following columns are returned:
+
+@multitable @columnfractions .30 .70
+@item @strong{Column} @tab @strong{Meaning}
+@item @code{Name} @tab Name of the table.
+@item @code{Type} @tab Type of table. @xref{Table types}.
+@item @code{Row_format} @tab The row storage format (Fixed, Dynamic, or Compressed).
+@item @code{Rows} @tab Number of rows.
+@item @code{Avg_row_length} @tab Average row length.
+@item @code{Data_length} @tab Length of the data file.
+@item @code{Max_data_length} @tab Max length of the data file.
+@item @code{Index_length} @tab Length of the index file.
+@item @code{Data_free} @tab Number of allocated but not used bytes.
+@item @code{Auto_increment} @tab Next autoincrement value.
+@item @code{Create_time} @tab When the table was created.
+@item @code{Update_time} @tab When the data file was last updated.
+@item @code{Check_time} @tab When the table was last checked.
+@item @code{Create_options} @tab Extra options used with @code{CREATE TABLE}.
+@item @code{Comment} @tab The comment used when creating the table (or some information why @strong{MySQL} couldn't access the table information).
+@end multitable
+
+@code{InnoDB} tables will report the free space in the tablespace
+in the table comment.
+
+
+@node SHOW STATUS, SHOW VARIABLES, SHOW TABLE STATUS, SHOW
+@subsubsection @code{SHOW STATUS}
+
+@cindex @code{mysqladmin}
+@code{SHOW STATUS} provides server status information
+(like @code{mysqladmin extended-status}). The output resembles that shown
+below, though the format and numbers probably differ:
+
+@example
++--------------------------+------------+
+| Variable_name | Value |
++--------------------------+------------+
+| Aborted_clients | 0 |
+| Aborted_connects | 0 |
+| Bytes_received | 155372598 |
+| Bytes_sent | 1176560426 |
+| Connections | 30023 |
+| Created_tmp_disk_tables | 0 |
+| Created_tmp_tables | 8340 |
+| Created_tmp_files | 60 |
+| Delayed_insert_threads | 0 |
+| Delayed_writes | 0 |
+| Delayed_errors | 0 |
+| Flush_commands | 1 |
+| Handler_delete | 462604 |
+| Handler_read_first | 105881 |
+| Handler_read_key | 27820558 |
+| Handler_read_next | 390681754 |
+| Handler_read_prev | 6022500 |
+| Handler_read_rnd | 30546748 |
+| Handler_read_rnd_next | 246216530 |
+| Handler_update | 16945404 |
+| Handler_write | 60356676 |
+| Key_blocks_used | 14955 |
+| Key_read_requests | 96854827 |
+| Key_reads | 162040 |
+| Key_write_requests | 7589728 |
+| Key_writes | 3813196 |
+| Max_used_connections | 0 |
+| Not_flushed_key_blocks | 0 |
+| Not_flushed_delayed_rows | 0 |
+| Open_tables | 1 |
+| Open_files | 2 |
+| Open_streams | 0 |
+| Opened_tables | 44600 |
+| Questions | 2026873 |
+| Select_full_join | 0 |
+| Select_full_range_join | 0 |
+| Select_range | 99646 |
+| Select_range_check | 0 |
+| Select_scan | 30802 |
+| Slave_running | OFF |
+| Slave_open_temp_tables | 0 |
+| Slow_launch_threads | 0 |
+| Slow_queries | 0 |
+| Sort_merge_passes | 30 |
+| Sort_range | 500 |
+| Sort_rows | 30296250 |
+| Sort_scan | 4650 |
+| Table_locks_immediate | 1920382 |
+| Table_locks_waited | 0 |
+| Threads_cached | 0 |
+| Threads_created | 30022 |
+| Threads_connected | 1 |
+| Threads_running | 1 |
+| Uptime | 80380 |
++--------------------------+------------+
+@end example
+
+@cindex variables, status
+The status variables listed above have the following meaning:
+
+@multitable @columnfractions .35 .65
+@item @strong{Variable} @tab @strong{Meaning}
+@item @code{Aborted_clients} @tab Number of connections aborted because the client died without closing the connection properly. @xref{Communication errors}.
+@item @code{Aborted_connects} @tab Number of tries to connect to the @strong{MySQL} server that failed. @xref{Communication errors}.
+@item @code{Bytes_received} @tab Number of bytes received from all clients.
+@item @code{Bytes_sent} @tab Number of bytes sent to all clients.
+@item @code{Connections} @tab Number of connection attempts to the @strong{MySQL} server.
+@item @code{Created_tmp_disk_tables} @tab Number of implicit temporary tables on disk created while executing statements.
+@item @code{Created_tmp_tables} @tab Number of implicit temporary tables in memory created while executing statements.
+@item @code{Created_tmp_files} @tab How many temporary files @code{mysqld} have created.
+@item @code{Delayed_insert_threads} @tab Number of delayed insert handler threads in use.
+@item @code{Delayed_writes} @tab Number of rows written with @code{INSERT DELAYED}.
+@item @code{Delayed_errors} @tab Number of rows written with @code{INSERT DELAYED} for which some error occurred (probably @code{duplicate key}).
+@item @code{Flush_commands} @tab Number of executed @code{FLUSH} commands.
+@item @code{Handler_delete} @tab Number of times a row was deleted from a table.
+@item @code{Handler_read_first} @tab Number of times the first entry was read from an index.
+If this is high, it suggests that the server is doing a lot of full index scans, for example,
+@code{SELECT col1 FROM foo}, assuming that col1 is indexed.
+@item @code{Handler_read_key} @tab Number of requests to read a row based on a key. If this
+is high, it is a good indication that your queries and tables are properly indexed.
+@item @code{Handler_read_next} @tab Number of requests to read next row in key order. This
+will be incremented if you are querying an index column with a range constraint. This also
+will be incremented if you are doing an index scan.
+@item @code{Handler_read_rnd} @tab Number of requests to read a row based on a fixed position.
+This will be high if you are doing a lot of queries that require sorting of the result.
+@item @code{Handler_read_rnd_next} @tab Number of requests to read the next row in the datafile.
+This will be high if you are doing a lot of table scans. Generally this suggests that your tables
+are not properly indexed or that your queries are not written to take advantage of the indexes you
+have.
+@item @code{Handler_update} @tab Number of requests to update a row in a table.
+@item @code{Handler_write} @tab Number of requests to insert a row in a table.
+@item @code{Key_blocks_used} @tab The number of used blocks in the key cache.
+@item @code{Key_read_requests} @tab The number of requests to read a key block from the cache.
+@item @code{Key_reads} @tab The number of physical reads of a key block from disk.
+@item @code{Key_write_requests} @tab The number of requests to write a key block to the cache.
+@item @code{Key_writes} @tab The number of physical writes of a key block to disk.
+@item @code{Max_used_connections} @tab The maximum number of connections in use simultaneously.
+@item @code{Not_flushed_key_blocks} @tab Keys blocks in the key cache that has changed but hasn't yet been flushed to disk.
+@item @code{Not_flushed_delayed_rows} @tab Number of rows waiting to be written in @code{INSERT DELAY} queues.
+@item @code{Open_tables} @tab Number of tables that are open.
+@item @code{Open_files} @tab Number of files that are open.
+@item @code{Open_streams} @tab Number of streams that are open (used mainly for logging).
+@item @code{Opened_tables} @tab Number of tables that have been opened.
+@item @code{Select_full_join} @tab Number of joins without keys (Should be 0).
+@item @code{Select_full_range_join} @tab Number of joins where we used a range search on reference table.
+@item @code{Select_range} @tab Number of joins where we used ranges on the first table. (It's normally not critical even if this is big.)
+@item @code{Select_scan} @tab Number of joins where we scanned the first table.
+@item @code{Select_range_check} @tab Number of joins without keys where we check for key usage after each row (Should be 0).
+@item @code{Questions} @tab Number of queries sent to the server.
+@item @code{Slave_open_temp_tables} @tab Number of temporary tables currently
+open by the slave thread
+@item @code{Slow_launch_threads} @tab Number of threads that have taken more than @code{slow_launch_time} to connect.
+@item @code{Slow_queries} @tab Number of queries that have taken more than @code{long_query_time}. @xref{Slow query log}.
+@item @code{Sort_merge_passes} @tab Number of merges the sort has to do. If this value is large you should consider increasing @code{sort_buffer}.
+@item @code{Sort_range} @tab Number of sorts that where done with ranges.
+@item @code{Sort_rows} @tab Number of sorted rows.
+@item @code{Sort_scan} @tab Number of sorts that where done by scanning the table.
+@item @code{Table_locks_immediate} @tab Number of times a table lock was
+acquired immediately. Available after 3.23.33.
+@item @code{Table_locks_waited} @tab Number of times a table lock could not
+be acquired immediately and a wait was needed. If this is high, and you
+have performance problems, you should first optimize your queries, and then
+either split your table(s) or use replication. Available after 3.23.33.
+@item @code{Threads_cached} @tab Number of threads in the thread cache.
+@item @code{Threads_connected} @tab Number of currently open connections.
+@item @code{Threads_created} @tab Number of threads created to handle connections.
+@item @code{Threads_running} @tab Number of threads that are not sleeping.
+@item @code{Uptime} @tab How many seconds the server has been up.
+@end multitable
+
+Some comments about the above:
+
+@itemize @bullet
+@item
+If @code{Opened_tables} is big, then your @code{table_cache}
+variable is probably too small.
+@item
+If @code{key_reads} is big, then your @code{key_cache} is probably too
+small. The cache hit rate can be calculated with
+@code{key_reads}/@code{key_read_requests}.
+@item
+If @code{Handler_read_rnd} is big, then you probably have a lot of
+queries that require @strong{MySQL} to scan whole tables or you have
+joins that don't use keys properly.
+@item
+If @code{Threads_created} is big, you may want to increase the
+@code{thread_cache_size} variable.
+@end itemize
+
+
+@node SHOW VARIABLES, SHOW LOGS, SHOW STATUS, SHOW
+@subsubsection @code{SHOW VARIABLES}
+
+@example
+SHOW VARIABLES [LIKE wild]
+@end example
+
+@code{SHOW VARIABLES} shows the values of some @strong{MySQL} system
+variables. You can also get this information using the @code{mysqladmin
+variables} command. If the default values are unsuitable, you can set most
+of these variables using command-line options when @code{mysqld} starts up.
+@xref{Command-line options}.
+
+The output resembles that shown below, though the format and numbers may
+differ somewhat:
+
+@example
++-------------------------+---------------------------+
+| Variable_name | Value |
++-------------------------+---------------------------+
+| ansi_mode | OFF |
+| back_log | 50 |
+| basedir | /my/monty/ |
+| bdb_cache_size | 16777216 |
+| bdb_log_buffer_size | 32768 |
+| bdb_home | /my/monty/data/ |
+| bdb_max_lock | 10000 |
+| bdb_logdir | |
+| bdb_shared_data | OFF |
+| bdb_tmpdir | /tmp/ |
+| binlog_cache_size | 32768 |
+| concurrent_insert | ON |
+| connect_timeout | 5 |
+| datadir | /my/monty/data/ |
+| delay_key_write | ON |
+| delayed_insert_limit | 100 |
+| delayed_insert_timeout | 300 |
+| delayed_queue_size | 1000 |
+| flush | OFF |
+| flush_time | 0 |
+| have_bdb | YES |
+| have_innodb | YES |
+| have_raid | YES |
+| have_ssl | NO |
+| init_file | |
+| interactive_timeout | 28800 |
+| join_buffer_size | 131072 |
+| key_buffer_size | 16776192 |
+| language | /my/monty/share/english/ |
+| large_files_support | ON |
+| log | OFF |
+| log_update | OFF |
+| log_bin | OFF |
+| log_slave_updates | OFF |
+| long_query_time | 10 |
+| low_priority_updates | OFF |
+| lower_case_table_names | 0 |
+| max_allowed_packet | 1048576 |
+| max_binlog_cache_size | 4294967295 |
+| max_connections | 100 |
+| max_connect_errors | 10 |
+| max_delayed_threads | 20 |
+| max_heap_table_size | 16777216 |
+| max_join_size | 4294967295 |
+| max_sort_length | 1024 |
+| max_tmp_tables | 32 |
+| max_write_lock_count | 4294967295 |
+| myisam_recover_options | DEFAULT |
+| myisam_sort_buffer_size | 8388608 |
+| net_buffer_length | 16384 |
+| net_read_timeout | 30 |
+| net_retry_count | 10 |
+| net_write_timeout | 60 |
+| open_files_limit | 0 |
+| pid_file | /my/monty/data/donna.pid |
+| port | 3306 |
+| protocol_version | 10 |
+| record_buffer | 131072 |
+| query_buffer_size | 0 |
+| safe_show_database | OFF |
+| server_id | 0 |
+| skip_locking | ON |
+| skip_networking | OFF |
+| skip_show_database | OFF |
+| slow_launch_time | 2 |
+| socket | /tmp/mysql.sock |
+| sort_buffer | 2097116 |
+| table_cache | 64 |
+| table_type | MYISAM |
+| thread_cache_size | 4 |
+| thread_stack | 65536 |
+| tmp_table_size | 1048576 |
+| tmpdir | /tmp/ |
+| version | 3.23.29a-gamma-debug |
+| wait_timeout | 28800 |
++-------------------------+---------------------------+
+@end example
+
+Each option is described below. Values for buffer sizes, lengths, and stack
+sizes are given in bytes. You can specify values with a suffix of @samp{K}
+or @samp{M} to indicate kilobytes or megabytes. For example, @code{16M}
+indicates 16 megabytes. The case of suffix letters does not matter;
+@code{16M} and @code{16m} are equivalent:
+
+@cindex variables, values
+@table @code
+@item @code{ansi_mode}.
+Is @code{ON} if @code{mysqld} was started with @code{--ansi}.
+@xref{ANSI mode}.
+
+@item @code{back_log}
+The number of outstanding connection requests @strong{MySQL} can have. This
+comes into play when the main @strong{MySQL} thread gets @strong{VERY}
+many connection requests in a very short time. It then takes some time
+(although very little) for the main thread to check the connection and start
+a new thread. The @code{back_log} value indicates how many requests can be
+stacked during this short time before @strong{MySQL} momentarily stops
+answering new requests. You need to increase this only if you expect a large
+number of connections in a short period of time.
+
+In other words, this value is the size of the listen queue for incoming
+TCP/IP connections. Your operating system has its own limit on the size
+of this queue. The manual page for the Unix @code{listen(2)} system
+call should have more details. Check your OS documentation for the
+maximum value for this variable. Attempting to set @code{back_log}
+higher than your operating system limit will be ineffective.
+
+@item @code{basedir}
+The value of the @code{--basedir} option.
+
+@item @code{bdb_cache_size}
+The buffer that is allocated to cache index and rows for @code{BDB}
+tables. If you don't use @code{BDB} tables, you should start
+@code{mysqld} with @code{--skip-bdb} to not waste memory for this
+cache.
+
+@item @code{bdb_log_buffer_size}
+The buffer that is allocated to cache index and rows for @code{BDB}
+tables. If you don't use @code{BDB} tables, you should set this to 0 or
+start @code{mysqld} with @code{--skip-bdb} to not waste memory for this
+cache.
+
+@item @code{bdb_home}
+The value of the @code{--bdb-home} option.
+
+@item @code{bdb_max_lock}
+The maximum number of locks (1000 by default) you can have active on a
+BDB table. You should increase this if you get errors of type @code{bdb:
+Lock table is out of available locks} or @code{Got error 12 from ...}
+when you have do long transactions or when @code{mysqld} has to examine
+a lot of rows to calculate the query.
+
+@item @code{bdb_logdir}
+The value of the @code{--bdb-logdir} option.
+
+@item @code{bdb_shared_data}
+Is @code{ON} if you are using @code{--bdb-shared-data}.
+
+@item @code{bdb_tmpdir}
+The value of the @code{--bdb-tmpdir} option.
+
+@item @code{binlog_cache_size}. The size of the cache to hold the SQL
+statements for the binary log during a transaction. If you often use
+big, multi-statement transactions you can increase this to get more
+performance. @xref{COMMIT}.
+
+@item @code{character_set}
+The default character set.
+
+@item @code{character_sets}
+The supported character sets.
+
+@item @code{concurrent_inserts}
+If @code{ON} (the default), @strong{MySQL} will allow you to use @code{INSERT}
+on @code{MyISAM} tables at the same time as you run @code{SELECT} queries
+on them. You can turn this option off by starting @code{mysqld} with @code{--safe}
+or @code{--skip-new}.
+
+@cindex timeout
+@item @code{connect_timeout}
+The number of seconds the @code{mysqld} server is waiting for a connect
+packet before responding with @code{Bad handshake}.
+
+@item @code{datadir}
+The value of the @code{--datadir} option.
+
+@item @code{delay_key_write}
+If enabled (is on by default), @strong{MySQL} will honor the
+@code{delay_key_write} option @code{CREATE TABLE}. This means that the
+key buffer for tables with this option will not get flushed on every
+index update, but only when a table is closed. This will speed up
+writes on keys a lot, but you should add automatic checking of all tables
+with @code{myisamchk --fast --force} if you use this. Note that if you
+start @code{mysqld} with the @code{--delay-key-write-for-all-tables}
+option this means that all tables will be treated as if they were
+created with the @code{delay_key_write} option. You can clear this flag
+by starting @code{mysqld} with @code{--skip-new} or @code{--safe-mode}.
+
+@item @code{delayed_insert_limit}
+After inserting @code{delayed_insert_limit} rows, the @code{INSERT
+DELAYED} handler will check if there are any @code{SELECT} statements
+pending. If so, it allows these to execute before continuing.
+
+@item @code{delayed_insert_timeout}
+How long a @code{INSERT DELAYED} thread should wait for @code{INSERT}
+statements before terminating.
+
+@item @code{delayed_queue_size}
+What size queue (in rows) should be allocated for handling @code{INSERT
+DELAYED}. If the queue becomes full, any client that does @code{INSERT
+DELAYED} will wait until there is room in the queue again.
+
+@item @code{flush}
+This is @code{ON} if you have started @strong{MySQL} with the @code{--flush}
+option.
+
+@item @code{flush_time}
+If this is set to a non-zero value, then every @code{flush_time} seconds all
+tables will be closed (to free up resources and sync things to disk). We
+only recommend this option on Win95, Win98, or on systems where you have
+very little resources.
+
+@item @code{have_bdb}
+@code{YES} if @code{mysqld} supports Berkeley DB tables. @code{DISABLED}
+if @code{--skip-bdb} is used.
+@item @code{have_innodb}
+@code{YES} if @code{mysqld} supports InnoDB tables. @code{DISABLED}
+if @code{--skip-innodb} is used.
+@item @code{have_raid}
+@code{YES} if @code{mysqld} supports the @code{RAID} option.
+@item @code{have_ssl}
+@code{YES} if @code{mysqld} supports SSL (encryption) on the client/server
+protocol.
+
+@item @code{init_file}
+The name of the file specified with the @code{--init-file} option when
+you start the server. This is a file of SQL statements you want the
+server to execute when it starts.
+
+@item @code{interactive_timeout}
+The number of seconds the server waits for activity on an interactive
+connection before closing it. An interactive client is defined as a
+client that uses the @code{CLIENT_INTERACTIVE} option to
+@code{mysql_real_connect()}. See also @code{wait_timeout}.
+
+@item @code{join_buffer_size}
+The size of the buffer that is used for full joins (joins that do not
+use indexes). The buffer is allocated one time for each full join
+between two tables. Increase this value to get a faster full join when
+adding indexes is not possible. (Normally the best way to get fast joins
+is to add indexes.)
+
+@c Make texi2html support index @anchor{Index cache size}. Then change
+@c some xrefs to point here
+@cindex indexes, block size
+@item @code{key_buffer_size}
+Index blocks are buffered and are shared by all threads.
+@code{key_buffer_size} is the size of the buffer used for index blocks.
+
+Increase this to get better index handling (for all reads and multiple
+writes) to as much as you can afford; 64M on a 256M machine that mainly
+runs @strong{MySQL} is quite common. If you, however, make this too big
+(more than 50% of your total memory?) your system may start to page and
+become REALLY slow. Remember that because @strong{MySQL} does not cache
+data read, that you will have to leave some room for the OS filesystem
+cache.
+
+You can check the performance of the key buffer by doing @code{show
+status} and examine the variables @code{Key_read_requests},
+@code{Key_reads}, @code{Key_write_requests}, and @code{Key_writes}. The
+@code{Key_reads/Key_read_request} ratio should normally be < 0.01.
+The @code{Key_write/Key_write_requests} is usually near 1 if you are
+using mostly updates/deletes but may be much smaller if you tend to
+do updates that affect many at the same time or if you are
+using @code{delay_key_write}. @xref{SHOW}.
+
+To get even more speed when writing many rows at the same time, use
+@code{LOCK TABLES}. @xref{LOCK TABLES, , @code{LOCK TABLES}}.
+
+@item @code{language}
+The language used for error messages.
+
+@item @code{large_file_support}
+If @code{mysqld} was compiled with options for big file support.
+
+@item @code{locked_in_memory}
+If @code{mysqld} was locked in memory with @code{--memlock}
+
+@item @code{log}
+If logging of all queries is enabled.
+
+@item @code{log_update}
+If the update log is enabled.
+
+@item @code{log_bin}
+If the binary log is enabled.
+
+@item @code{log_slave_updates}
+If the updates from the slave should be logged.
+
+@item @code{long_query_time}
+If a query takes longer than this (in seconds), the @code{Slow_queries} counter
+will be incremented. If you are using @code{--log-slow-queries}, the query
+will be logged to the slow query logfile. @xref{Slow query log}.
+
+@item @code{lower_case_table_names}
+If set to 1 table names are stored in lowercase on disk. This will enable
+you to access the table names case-insensitive also on Unix.
+@xref{Name case sensitivity}.
+
+@item @code{max_allowed_packet}
+The maximum size of one packet. The message buffer is initialized to
+@code{net_buffer_length} bytes, but can grow up to @code{max_allowed_packet}
+bytes when needed. This value by default is small, to catch big (possibly
+wrong) packets. You must increase this value if you are using big
+@code{BLOB} columns. It should be as big as the biggest @code{BLOB} you want
+to use. The current protocol limits @code{max_allowed_packet} to 16M.
+
+@item @code{max_binlog_cache_size}
+If a multi-statement transaction requires more than this amount of memory,
+one will get the error "Multi-statement transaction required more than
+'max_binlog_cache_size' bytes of storage".
+
+@item @code{max_binlog_size}
+Available after 3.23.33. If a write to the binary (replication) log exceeds
+the given value, rotate the logs. You cannot set it to less than 1024 bytes,
+or more than 1 GB. Default is 1 GB.
+
+@item @code{max_connections}
+The number of simultaneous clients allowed. Increasing this value increases
+the number of file descriptors that @code{mysqld} requires. See below for
+comments on file descriptor limits. @xref{Too many connections}.
+
+@item @code{max_connect_errors}
+If there is more than this number of interrupted connections from a host
+this host will be blocked from further connections. You can unblock a host
+with the command @code{FLUSH HOSTS}.
+
+@item @code{max_delayed_threads}
+Don't start more than this number of threads to handle @code{INSERT DELAYED}
+statements. If you try to insert data into a new table after all @code{INSERT
+DELAYED} threads are in use, the row will be inserted as if the
+@code{DELAYED} attribute wasn't specified.
+
+@item @code{max_heap_table_size}
+Don't allow creation of heap tables bigger than this.
+
+@item @code{max_join_size}
+Joins that are probably going to read more than @code{max_join_size}
+records return an error. Set this value if your users tend to perform joins
+that lack a @code{WHERE} clause, that take a long time, and that return
+millions of rows.
+
+@item @code{max_sort_length}
+The number of bytes to use when sorting @code{BLOB} or @code{TEXT}
+values (only the first @code{max_sort_length} bytes of each value
+are used; the rest are ignored).
+
+@item @code{max_user_connections}
+The maximum number of active connections for a single user (0 = no limit).
+
+@item @code{max_tmp_tables}
+(This option doesn't yet do anything.)
+Maximum number of temporary tables a client can keep open at the same time.
+
+@item @code{max_write_lock_count}
+After this many write locks, allow some read locks to run in between.
+
+@item @code{myisam_recover_options}
+The value of the @code{--myisam-recover} option.
+
+@item @code{myisam_sort_buffer_size}
+The buffer that is allocated when sorting the index when doing a
+@code{REPAIR} or when creating indexes with @code{CREATE INDEX} or
+@code{ALTER TABLE}.
+
+@item @code{myisam_max_extra_sort_file_size}.
+If the creating of the temporary file for fast index creation would be
+this much bigger than using the key cache, then prefer the key cache
+method. This is mainly used to force long character keys in large
+tables to use the slower key cache method to create the index.
+@strong{NOTE} that this parameter is given in megabytes!
+
+@item @code{myisam_max_sort_file_size}
+The maximum size of the temporary file @strong{MySQL} is allowed to use
+while recreating the index (during @code{REPAIR}, @code{ALTER TABLE}
+or @code{LOAD DATA INFILE}. If the file size would be bigger than this,
+the index will be created through the key cache (which is slower).
+@strong{NOTE} that this parameter is given in megabytes!
+
+@item @code{net_buffer_length}
+The communication buffer is reset to this size between queries. This
+should not normally be changed, but if you have very little memory, you
+can set it to the expected size of a query. (That is, the expected length of
+SQL statements sent by clients. If statements exceed this length, the buffer
+is automatically enlarged, up to @code{max_allowed_packet} bytes.)
+
+@item @code{net_read_timeout}
+Number of seconds to wait for more data from a connection before aborting
+the read. Note that when we don't expect data from a connection, the timeout
+is defined by @code{write_timeout}. See also @code{slave_read_timeout}.
+
+@item @code{net_retry_count}
+If a read on a communication port is interrupted, retry this many times
+before giving up. This value should be quite high on @code{FreeBSD} as
+internal interrupts are sent to all threads.
+
+@item @code{net_write_timeout}
+Number of seconds to wait for a block to be written to a connection before
+aborting the write.
+
+@item @code{open_files_limit}
+If this is not 0, then @code{mysqld} will use this value to reserve file
+descriptors to use with @code{setrlimit()}. If this value is 0 then
+@code{mysqld} will reserve @code{max_connections*5} or
+@code{max_connections + table_cache*2} (whichever is larger) number of
+files. You should try increasing this if @code{mysqld} gives you the
+error 'Too many open files'.
+
+@item @code{pid_file}
+The value of the @code{--pid-file} option.
+
+@item @code{port}
+The value of the @code{--port} option.
+
+@item @code{protocol_version}
+The protocol version used by the @strong{MySQL} server.
+
+@item @code{record_buffer}
+Each thread that does a sequential scan allocates a buffer of this
+size for each table it scans. If you do many sequential scans, you may
+want to increase this value.
+
+@item @code{query_buffer_size}
+The initial allocation of the query buffer. If most of your queries are
+long (like when inserting blobs), you should increase this!
+
+@item @code{safe_show_databases}
+Don't show databases for which the user doesn't have any database or
+table privileges. This can improve security if you're concerned about
+people being able to see what databases other users have. See also
+@code{skip_show_databases}.
+
+@item @code{server_id}
+The value of the @code{--server-id} option.
+
+@item @code{skip_locking}
+Is OFF if @code{mysqld} uses external locking.
+
+@item @code{skip_networking}
+Is ON if we only allow local (socket) connections.
+
+@item @code{skip_show_databases}
+This prevents people from doing @code{SHOW DATABASES} if they don't have
+the @code{PROCESS_PRIV} privilege. This can improve security if you're
+concerned about people being able to see what databases other users
+have. See also @code{safe_show_databases}.
+
+@item @code{slave_read_timeout}
+Number of seconds to wait for more data from a master/slave connection
+before aborting the read.
+
+@item @code{slow_launch_time}
+If creating the thread takes longer than this value (in seconds), the
+@code{Slow_launch_threads} counter will be incremented.
+
+@item @code{socket}
+The Unix socket used by the server.
+
+@item @code{sort_buffer}
+Each thread that needs to do a sort allocates a buffer of this
+size. Increase this value for faster @code{ORDER BY} or @code{GROUP BY}
+operations.
+@xref{Temporary files}.
+
+@item @code{table_cache}
+The number of open tables for all threads. Increasing this value
+increases the number of file descriptors that @code{mysqld} requires.
+@strong{MySQL} needs two file descriptors for each unique open table.
+See below for comments on file descriptor limits. You can check if you
+need to increase the table cache by checking the @code{Opened_tables}
+variable. @xref{SHOW}. If this variable is big and you don't do
+@code{FLUSH TABLES} a lot (which just forces all tables to be closed and
+reopenend), then you should increase the value of this variable.
+
+Make sure that your operating system can handle the number of open file
+descriptors implied by the @code{table_cache} setting. If @code{table_cache}
+is set too high, @strong{MySQL} may run out of file descriptors and refuse
+connections, fail to perform queries, and be very unreliable.
+
+For information about how the table cache works, see @ref{Table cache}.
+
+@item @code{table_type}
+The default table type
+
+@item @code{thread_cache_size}
+How many threads we should keep in a cache for reuse. When a
+client disconnects, the client's threads are put in the cache if there
+aren't more than @code{thread_cache_size} threads from before. All new
+threads are first taken from the cache, and only when the cache is empty
+is a new thread created. This variable can be increased to improve
+performance if you have a lot of new connections. (Normally this doesn't
+give a notable performance improvement if you have a good
+thread implementation.) By examing the difference between
+the @code{Connections} and @code{Threads_created} you can see how efficient
+the current thread cache is for you.
+
+@item @code{thread_concurrency}
+On Solaris, @code{mysqld} will call @code{thr_setconcurrency()} with
+this value. @code{thr_setconcurrency()} permits the application to give
+the threads system a hint for the desired number of threads that should
+be run at the same time.
+
+@item @code{thread_stack}
+The stack size for each thread. Many of the limits detected by the
+@code{crash-me} test are dependent on this value. The default is
+large enough for normal operation. @xref{Benchmarks}.
+
+@item @code{timezone}
+The timezone for the server.
+
+@item @code{tmp_table_size}
+If an in-memory temporary table exceeds this size, @strong{MySQL}
+will automatically convert it to an on-disk @code{MyISAM} table.
+Increase the value of @code{tmp_table_size} if you do many advanced
+@code{GROUP BY} queries and you have lots of memory.
+
+@item @code{tmpdir}
+The directory used for temporary files and temporary tables.
+
+@item @code{version}
+The version number for the server.
+
+@item @code{wait_timeout}
+The number of seconds the server waits for activity on a connection before
+closing it. See also @code{interactive_timeout}.
+@end table
+
+The manual section that describes tuning @strong{MySQL} contains some
+information of how to tune the above variables. @xref{Server parameters}.
+
+
+@node SHOW LOGS, SHOW PROCESSLIST, SHOW VARIABLES, SHOW
+@subsubsection @code{SHOW LOGS}
+
+@code{SHOW LOGS} shows you status information about existing log
+files. It currently only displays information about Berkeley DB log
+files.
+
+@itemize @bullet
+@item @code{File} shows the full path to the log file
+@item @code{Type} shows the type of the log file (@code{BDB} for Berkeley
+DB log files)
+@item @code{Status} shows the status of the log file (@code{FREE} if the
+file can be removed, or @code{IN USE} if the file is needed by the transaction
+subsystem)
@end itemize
+
+@node SHOW PROCESSLIST, SHOW GRANTS, SHOW LOGS, SHOW
+@subsubsection @code{SHOW PROCESSLIST}
+
+@findex threads
+@findex PROCESSLIST
+
+@cindex threads, display
+@cindex processes, display
+
+@code{SHOW PROCESSLIST} shows you which threads are running. You can
+also get this information using the @code{mysqladmin processlist}
+command. If you have the @strong{process} privilege, you can see all
+threads. Otherwise, you can see only your own threads. @xref{KILL, ,
+@code{KILL}}. If you don't use the @code{FULL} option, then only
+the first 100 characters of each query will be shown.
+
+This command is very useful if you get the 'too many connections' error
+message and want to find out what's going on. @strong{MySQL} reserves
+one extra connection for a client with the @code{Process_priv} privilege
+to ensure that you should always be able to login and check the system
+(assuming you are not giving this privilege to all your users).
+
+
+@node SHOW GRANTS, SHOW CREATE TABLE, SHOW PROCESSLIST, SHOW
+@subsubsection @code{SHOW GRANTS}
+
+@cindex privileges, display
+
+@code{SHOW GRANTS FOR user} lists the grant commands that must be issued to
+duplicate the grants for a user.
+
+@example
+mysql> SHOW GRANTS FOR root@@localhost;
++---------------------------------------------------------------------+
+| Grants for root@@localhost |
++---------------------------------------------------------------------+
+| GRANT ALL PRIVILEGES ON *.* TO 'root'@@'localhost' WITH GRANT OPTION |
++---------------------------------------------------------------------+
+@end example
+
+
+@node SHOW CREATE TABLE, , SHOW GRANTS, SHOW
+@subsubsection @code{SHOW CREATE TABLE}
+
+Shows a @code{CREATE TABLE} statement that will create the given table:
+
+@example
+mysql> show create table t\G
+*************************** 1. row ***************************
+ Table: t
+Create Table: CREATE TABLE t (
+ id int(11) default NULL auto_increment,
+ s char(60) default NULL,
+ PRIMARY KEY (id)
+) TYPE=MyISAM
+
+@end example
+
+@code{SHOW CREATE TABLE} will quote table and column names according to
+@code{SQL_QUOTE_SHOW_CREATE} option.
+@ref{SET OPTION, , @code{SET OPTION SQL_QUOTE_SHOW_CREATE}}.
+
+
+@node Localization, Server-Side Scripts, KILL, MySQL Database Administration
+@section MySQL Localization and International Usage
+
+@menu
+* Character sets::
+* Languages::
+* Adding character set::
+* Character arrays::
+* String collating::
+* Multi-byte characters::
+@end menu
+
+
+@node Character sets, Languages, Localization, Localization
+@subsection The Character Set Used for Data and Sorting
+
+@cindex character sets
+@cindex data, character sets
+@cindex sorting, character sets
+
+By default, @strong{MySQL} uses the ISO-8859-1 (Latin1) character set
+with sorting according to Swedish/Finnish. This is the character set suitable
+in the USA and western Europe.
+
+All standard @strong{MySQL} binaries are compiled with
+@code{--with-extra-charsets=complex}. This will add code to all
+standard programs to be able to handle @code{latin1} and all multi-byte
+character sets within the binary. Other character sets will be
+loaded from a character-set definition file when needed.
+
+The character set determines what characters are allowed in names and how
+things are sorted by the @code{ORDER BY} and @code{GROUP BY} clauses of
+the @code{SELECT} statement.
+
+You can change the character set with the @code{--default-character-set}
+option when you start the server. The character sets available depend
+on the @code{--with-charset=charset} and @code{--with-extra-charset=
+list-of-charset | complex | all} options to @code{configure}, and the
+character set configuration files listed in
+@file{SHAREDIR/charsets/Index}. @xref{configure options}.
+
+If you change the character set when running @strong{MySQL} (which may
+also change the sort order), you must run myisamchk -r -q on all
+tables. Otherwise your indexes may not be ordered correctly.
+
+When a client connects to a @strong{MySQL} server, the server sends the
+default character set in use to the client. The client will switch to
+use this character set for this connection.
+
+One should use @code{mysql_real_escape_string()} when escaping strings
+for a SQL query. @code{mysql_real_escape_string()} is identical to the
+old @code{mysql_escape_string()} function, except that it takes the MYSQL
+connection handle as the first parameter.
+
+If the client is compiled with different paths than where the server is
+installed and the user who configured @strong{MySQL} didn't included all
+character sets in the @strong{MySQL} binary, one must specify for
+the client where it can find the additional character sets it will need
+if the server runs with a different character set than the client.
+
+One can specify this by putting in a @strong{MySQL} option file:
+
+@example
+[client]
+character-sets-dir=/usr/local/mysql/share/mysql/charsets
+@end example
+
+where the path points to where the dynamic @strong{MySQL} character sets
+are stored.
+
+One can force the client to use specific character set by specifying:
+
+@example
+[client]
+default-character-set=character-set-name
+@end example
+
+but normally this is never needed.
+
+
+@node Languages, Adding character set, Character sets, Localization
+@subsection Non-English Error Messages
+
+@cindex error messages, languages
+@cindex messages, languages
+@cindex files, error messages
+@cindex language support
+
+@code{mysqld} can issue error messages in the following languages:
+Czech, Danish, Dutch, English (the default), Estonian, French, German, Greek,
+Hungarian, Italian, Japanese, Korean, Norwegian, Norwegian-ny, Polish,
+Portuguese, Romanian, Russian, Slovak, Spanish, and Swedish.
+
+To start @code{mysqld} with a particular language, use either the
+@code{--language=lang} or @code{-L lang} options. For example:
+
+@example
+shell> mysqld --language=swedish
+@end example
+
+or:
+
+@example
+shell> mysqld --language=/usr/local/share/swedish
+@end example
+
+Note that all language names are specified in lowercase.
+
+The language files are located (by default) in
+@file{@var{mysql_base_dir}/share/@var{LANGUAGE}/}.
+
+To update the error message file, you should edit the @file{errmsg.txt} file
+and execute the following command to generate the @file{errmsg.sys} file:
+
+@example
+shell> comp_err errmsg.txt errmsg.sys
+@end example
+
+If you upgrade to a newer version of @strong{MySQL}, remember to repeat
+your changes with the new @file{errmsg.txt} file.
+
+
+@node Adding character set, Character arrays, Languages, Localization
+@subsection Adding a New Character Set
+
+@cindex character sets, adding
+@cindex adding, character sets
+
+To add another character set to @strong{MySQL}, use the following procedure.
+
+Decide if the set is simple or complex. If the character set
+does not need to use special string collating routines for
+sorting and does not need multi-byte character support, it is
+simple. If it needs either of those features, it is complex.
+
+For example, @code{latin1} and @code{danish} are simple charactersets while
+@code{big5} or @code{czech} are complex character sets.
+
+In the following section, we have assumed that you name your character
+set @code{MYSET}.
+
+For a simple character set do the following:
+
+@enumerate
@item
-If @code{mysql -u root test} works but @code{mysql -h your_hostname -u root
-test} results in @code{Access denied}, then you may not have the correct name
-for your host in the @code{user} table. A common problem here is that the
-@code{Host} value in the user table entry specifies an unqualified hostname,
-but your system's name resolution routines return a fully qualified domain
-name (or vice-versa). For example, if you have an entry with host
-@code{'tcx'} in the @code{user} table, but your DNS tells @strong{MySQL} that
-your hostname is @code{'tcx.subnet.se'}, the entry will not work. Try adding
-an entry to the @code{user} table that contains the IP number of your host as
-the @code{Host} column value. (Alternatively, you could add an entry to the
-@code{user} table with a @code{Host} value that contains a wild card---for
-example, @code{'tcx.%'}. However, use of hostnames ending with @samp{%} is
-@emph{insecure} and is @emph{not} recommended!)
+Add MYSET to the end of the @file{sql/share/charsets/Index} file
+Assign an unique number to it.
@item
-If @code{mysql -u user_name test} works but @code{mysql -u user_name
-other_db_name} doesn't work, you don't have an entry for @code{other_db_name}
-listed in the @code{db} table.
+Create the file @file{sql/share/charsets/MYSET.conf}.
+(You can use @file{sql/share/charsets/latin1.conf} as a base for this).
+
+The syntax for the file very simple:
+@itemize @bullet
@item
-If @code{mysql -u user_name db_name} works when executed on the server
-machine, but @code{mysql -u host_name -u user_name db_name} doesn't work when
-executed on another client machine, you don't have the client machine listed
-in the @code{user} table or the @code{db} table.
+Comments start with a '#' character and proceed to the end of the line.
+@item
+Words are separated by arbitrary amounts of whitespace.
+@item
+When defining the character set, every word must be a number in hexadecimal
+format
+@item
+The @code{ctype} array takes up the first 257 words. The
+@code{to_lower}, @code{to_upper} and @code{sort_order} arrays take up
+256 words each after that.
+@end itemize
+
+@xref{Character arrays}.
@item
-If you can't figure out why you get @code{Access denied}, remove from the
-@code{user} table all entries that have @code{Host} values containing
-wild cards (entries that contain @samp{%} or @samp{_}). A very common error
-is to insert a new entry with @code{Host}=@code{'%'} and
-@code{User}=@code{'some user'}, thinking that this will allow you to specify
-@code{localhost} to connect from the same machine. The reason that this
-doesn't work is that the default privileges include an entry with
-@code{Host}=@code{'localhost'} and @code{User}=@code{''}. Because that entry
-has a @code{Host} value @code{'localhost'} that is more specific than
-@code{'%'}, it is used in preference to the new entry when connecting from
-@code{localhost}! The correct procedure is to insert a second entry with
-@code{Host}=@code{'localhost'} and @code{User}=@code{'some_user'}, or to
-remove the entry with @code{Host}=@code{'localhost'} and
-@code{User}=@code{''}.
+Add the character set name to the @code{CHARSETS_AVAILABLE} and
+@code{COMPILED_CHARSETS} lists in @code{configure.in}.
@item
-If you get the following error, you may have a problem with the @code{db} or
-@code{host} table:
+Reconfigure, recompile, and test.
+
+@end enumerate
+
+For a complex character set do the following:
+
+@enumerate
+@item
+Create the file @file{strings/ctype-MYSET.c} in the @strong{MySQL} source
+distribution.
+
+@item
+Add MYSET to the end of the @file{sql/share/charsets/Index} file.
+Assign an unique number to it.
+
+@item
+Look at one of the existing @file{ctype-*.c} files to see what needs to
+be defined, for example @file{strings/ctype-big5.c}. Note that the
+arrays in your file must have names like @code{ctype_MYSET},
+@code{to_lower_MYSET}, and so on. This corresponds to the arrays
+in the simple character set. @xref{Character arrays}. For a complex
+character set
+
+@item
+Near the top of the file, place a special comment like this:
@example
-Access to database denied
+/*
+ * This comment is parsed by configure to create ctype.c,
+ * so don't change it unless you know what you are doing.
+ *
+ * .configure. number_MYSET=MYNUMBER
+ * .configure. strxfrm_multiply_MYSET=N
+ * .configure. mbmaxlen_MYSET=N
+ */
@end example
-If the entry selected from the @code{db} table has an empty value in the
-@code{Host} column, make sure there are one or more corresponding entries in
-the @code{host} table specifying which hosts the @code{db} table entry
-applies to.
+The @code{configure} program uses this comment to include
+the character set into the @strong{MySQL} library automatically.
-If you get the error when using the SQL commands @code{SELECT ...
-INTO OUTFILE} or @code{LOAD DATA INFILE}, your entry in the @code{user} table
-probably doesn't have the @strong{file} privilege enabled.
+The strxfrm_multiply and mbmaxlen lines will be explained in
+the following sections. Only include them if you the string
+collating functions or the multi-byte character set functions,
+respectively.
@item
-@cindex configuration files
+You should then create some of the following functions:
+
+@itemize @bullet
+@item @code{my_strncoll_MYSET()}
+@item @code{my_strcoll_MYSET()}
+@item @code{my_strxfrm_MYSET()}
+@item @code{my_like_range_MYSET()}
+@end itemize
+
+@xref{String collating}.
+
+@item
+Add the character set name to the @code{CHARSETS_AVAILABLE} and
+@code{COMPILED_CHARSETS} lists in @code{configure.in}.
+
+@item
+Reconfigure, recompile, and test.
+@end enumerate
+
+The file @file{sql/share/charsets/README} includes some more instructions.
+
+If you want to have the character set included in the @strong{MySQL}
+distribution, mail a patch to @email{internals@@lists.mysql.com}.
+
+
+@node Character arrays, String collating, Adding character set, Localization
+@subsection The character definition arrays
+
+@code{to_lower[]} and @code{to_upper[]} are simple arrays that hold the
+lowercase and uppercase characters corresponding to each member of the
+character set. For example:
+
+@example
+to_lower['A'] should contain 'a'
+to_upper['a'] should contain 'A'
+@end example
+
+@code{sort_order[]} is a map indicating how characters should be ordered for
+comparison and sorting purposes. For many character sets, this is the same as
+@code{to_upper[]} (which means sorting will be case insensitive).
+@strong{MySQL} will sort characters based on the value of
+@code{sort_order[character]}. For more complicated sorting rules, see
+the discussion of string collating below. @xref{String collating}.
+
+@code{ctype[]} is an array of bit values, with one element for one character.
+(Note that @code{to_lower[]}, @code{to_upper[]}, and @code{sort_order[]}
+are indexed by character value, but @code{ctype[]} is indexed by character
+value + 1. This is an old legacy to be able to handle EOF.)
+
+You can find the following bitmask definitions in @file{m_ctype.h}:
+
+@example
+#define _U 01 /* Uppercase */
+#define _L 02 /* Lowercase */
+#define _N 04 /* Numeral (digit) */
+#define _S 010 /* Spacing character */
+#define _P 020 /* Punctuation */
+#define _C 040 /* Control character */
+#define _B 0100 /* Blank */
+#define _X 0200 /* heXadecimal digit */
+@end example
+
+The @code{ctype[]} entry for each character should be the union of the
+applicable bitmask values that describe the character. For example,
+@code{'A'} is an uppercase character (@code{_U}) as well as a
+hexadecimal digit (@code{_X}), so @code{ctype['A'+1]} should contain the
+value:
+
+@example
+_U + _X = 01 + 0200 = 0201
+@end example
+
+
+@node String collating, Multi-byte characters, Character arrays, Localization
+@subsection String Collating Support
+
+@cindex collating, strings
+@cindex string collating
+
+If the sorting rules for your language are too complex to be handled
+with the simple @code{sort_order[]} table, you need to use the string
+collating functions.
+
+Right now the best documentation on this is the character sets that are
+already implemented. Look at the big5, czech, gbk, sjis, and tis160
+character sets for examples.
+
+You must specify the @code{strxfrm_multiply_MYSET=N} value in the
+special comment at the top of the file. @code{N} should be set to
+the maximum ratio the strings may grow during @code{my_strxfrm_MYSET} (it
+must be a positive integer).
+
+
+@node Multi-byte characters, , String collating, Localization
+@subsection Multi-byte Character Support
+
+@cindex characters, multi-byte
+@cindex multi-byte characters
+
+If your want to add support for a new character set that includes
+multi-byte characters, you need to use the multi-byte character
+functions.
+
+Right now the best documentation on this is the character sets that are
+already implemented. Look at the euc_kr, gb2312, gbk, sjis and ujis
+character sets for examples. These are implemented in the
+@code{ctype-'charset'.c} files in the @file{strings} directory.
+
+You must specify the @code{mbmaxlen_MYSET=N} value in the special
+comment at the top of the source file. @code{N} should be set to the
+size in bytes of the largest character in the set.
+
+
+@node Server-Side Scripts, Client-Side Scripts, Localization, MySQL Database Administration
+@section MySQL Server-Side Scripts and Utilities
+
+@menu
+* Server-Side Overview::
+* safe_mysqld::
+* mysqld_multi::
+* myisampack::
+* mysqld-max::
+@end menu
+
+
+@node Server-Side Overview, safe_mysqld, Server-Side Scripts, Server-Side Scripts
+@subsection Overview of the Server-Side Scripts and Utilities
+
@cindex environment variables
-@tindex .my.cnf file
-Remember that client programs will use connection parameters specified
-in configuration files or environment variables. @xref{Environment
-variables}. If a client seems to be sending the wrong default
-connection parameters when you don't specify them on the command line,
-check your environment and the @file{.my.cnf} file in your home
-directory. You might also check the system-wide @strong{MySQL}
-configuration files, though it is far less likely that client connection
-parameters will be specified there. @xref{Option files}. If you get
-@code{Access denied} when you run a client without any options, make
-sure you haven't specified an old password in any of your option files!
+@cindex programs, list of
+
+All @strong{MySQL} clients that communicate with the server using the
+@code{mysqlclient} library use the following environment variables:
+
+@tindex MYSQL_UNIX_PORT environment variable
+@tindex Environment variable, MYSQL_UNIX_PORT
+@tindex MYSQL_TCP_PORT environment variable
+@tindex Environment variable, MYSQL_TCP_PORT
+@tindex MYSQL_PWD environment variable
+@tindex Environment variable, MYSQL_PWD
+@tindex MYSQL_DEBUG environment variable
+@tindex Environment variable, MYSQL_DEBUG
+@multitable @columnfractions .25 .75
+@item @strong{Name} @tab @strong{Description}
+@item @code{MYSQL_UNIX_PORT} @tab The default socket; used for connections to @code{localhost}
+@item @code{MYSQL_TCP_PORT} @tab The default TCP/IP port
+@item @code{MYSQL_PWD} @tab The default password
+@item @code{MYSQL_DEBUG} @tab Debug-trace options when debugging
+@item @code{TMPDIR} @tab The directory where temporary tables/files are created
+@end multitable
+
+Use of @code{MYSQL_PWD} is insecure.
+@xref{Connecting}.
+
+@tindex MYSQL_HISTFILE environment variable
+@tindex Environment variable, MYSQL_HISTFILE
+@tindex HOME environment variable
+@tindex Environment variable, HOME
+@cindex history file
+@cindex command line history
+@tindex .mysql_history file
+The @file{mysql} client uses the file named in the @code{MYSQL_HISTFILE}
+environment variable to save the command-line history. The default value for
+the history file is @file{$HOME/.mysql_history}, where @code{$HOME} is the
+value of the @code{HOME} environment variable. @xref{Environment variables}.
+
+All @strong{MySQL} programs take many different options. However, every
+@strong{MySQL} program provides a @code{--help} option that you can use
+to get a full description of the program's different options. For example, try
+@code{mysql --help}.
+
+You can override default options for all standard client programs with an
+option file. @ref{Option files}.
+
+The list below briefly describes the @strong{MySQL} programs:
+
+@table @code
+
+@cindex @code{myisamchk}
+@item myisamchk
+Utility to describe, check, optimize, and repair @strong{MySQL} tables.
+Because @code{myisamchk} has many functions, it is described in its own
+chapter. @xref{Maintenance}.
+
+@cindex @code{make_binary_distribution}
+@item make_binary_distribution
+Makes a binary release of a compiled @strong{MySQL}. This could be sent
+by FTP to @file{/pub/mysql/Incoming} on @code{support.mysql.com} for the
+convenience of other @strong{MySQL} users.
+
+@cindex @code{msql2mysql}
+@item msql2mysql
+A shell script that converts @code{mSQL} programs to @strong{MySQL}. It doesn't
+handle all cases, but it gives a good start when converting.
+
+@cindex @code{mysqlaccess}
+@item mysqlaccess
+A script that checks the access privileges for a host, user, and database
+combination.
+
+@cindex @code{mysqladmin}
+@item mysqladmin
+Utility for performing administrative operations, such as creating or
+dropping databases, reloading the grant tables, flushing tables to disk, and
+reopening log files. @code{mysqladmin} can also be used to retrieve version,
+process, and status information from the server.
+@xref{mysqladmin, , @code{mysqladmin}}.
+
+@cindex @code{mysqlbug}
+@item mysqlbug
+The @strong{MySQL} bug report script. This script should always be used when
+filing a bug report to the @strong{MySQL} list.
+
+@cindex @code{mysqld}
+@item mysqld
+The SQL daemon. This should always be running.
+
+@cindex @code{mysqldump}
+@item mysqldump
+Dumps a @strong{MySQL} database into a file as SQL statements or
+as tab-separated text files. Enhanced freeware originally by Igor Romanenko.
+@xref{mysqldump, , @code{mysqldump}}.
+
+@cindex @code{mysqlimport}
+@item mysqlimport
+Imports text files into their respective tables using @code{LOAD DATA
+INFILE}. @xref{mysqlimport, , @code{mysqlimport}}.
+
+@cindex @code{mysqlshow}
+@item mysqlshow
+Displays information about databases, tables, columns, and indexes.
+
+@cindex @code{mysql_install_db}
+@item mysql_install_db
+Creates the @strong{MySQL} grant tables with default privileges. This is
+usually executed only once, when first installing @strong{MySQL}
+on a system.
+
+@cindex @code{replace}
+@item replace
+A utility program that is used by @code{msql2mysql}, but that has more
+general applicability as well. @code{replace} changes strings in place in
+files or on the standard input. Uses a finite state machine to match longer
+strings first. Can be used to swap strings. For example, this command
+swaps @code{a} and @code{b} in the given files:
+
+@example
+shell> replace a b b a -- file1 file2 ...
+@end example
+@end table
+
+
+@node safe_mysqld, mysqld_multi, Server-Side Overview, Server-Side Scripts
+@subsection safe_mysqld, the wrapper around mysqld
+
+@cindex tools, safe_mysqld
+@cindex scripts
+@cindex @code{safe_mysqld}
+
+@code{safe_mysqld} is the recommended way to start a @code{mysqld}
+daemon on Unix. @code{safe_mysqld} adds some safety features such as
+restarting the server when an error occurs and logging run-time
+information to a log file.
+
+If you don't use @code{--mysqld=#} or @code{--mysqld-version=#}
+@code{safe_mysqld} will use an executable named @code{mysqld-max} if it
+exists. If not, @code{safe_mysqld} will start @code{mysqld}.
+This makes it very easy to test to use @code{mysqld-max} instead of
+@code{mysqld}; Just copy @code{mysqld-max} to where you have
+@code{mysqld} and it will be used.
+
+Normally one should never edit the @code{safe_mysqld} script, but
+instead put the options to @code{safe_mysqld} in the
+@code{[safe_mysqld]} section in the @code{my.cnf}
+file. @code{safe_mysqld} will read all options from the @code{[mysqld]},
+@code{[server]} and @code{[safe_mysqld]} sections from the option files.
@xref{Option files}.
+Note that all options on the command line to @code{safe_mysqld} are passed
+to @code{mysqld}. If you wants to use any options in @code{safe_mysqld} that
+@code{mysqld} doesn't support, you must specify these in the option file.
+
+Most of the options to @code{safe_mysqld} are the same as the options to
+@code{mysqld}. @xref{Command-line options}.
+
+@code{safe_mysqld} supports the following options:
+
+@table @code
+@item --basedir=path
+@item --core-file-size=#
+Size of the core file @code{mysqld} should be able to create. Passed to @code{ulimit -c}.
+@item --datadir=path
+@item --defaults-extra-file=path
+@item --defaults-file=path
+@item --err-log=path
+@item --ledir=path
+Path to @code{mysqld}
+@item --log=path
+@item --mysqld=mysqld-version
+Name of the @code{mysqld} version in the @code{ledir} directory you want to start.
+@item --mysqld-version=version
+Similar to @code{--mysqld=} but here you only give the suffix for @code{mysqld}.
+For example if you use @code{--mysqld-version=max}, @code{safe_mysqld} will
+start the @code{ledir/mysqld-max} version. If the argument to
+@code{--mysqld-version} is empty, @code{ledir/mysqld} will be used.
+@item --no-defaults
+@item --open-files-limit=#
+Number of files @code{mysqld} should be able to open. Passed to @code{ulimit -n}. Note that you need to start @code{safe_mysqld} as root for this to work properly!
+@item --pid-file=path
+@item --port=#
+@item --socket=path
+@item --timezone=#
+Set the timezone (the @code{TZ}) variable to the value of this parameter.
+@item --user=#
+@end table
+
+The @code{safe_mysqld} script is written so that it normally is able to start
+a server that was installed from either a source or a binary version of
+@strong{MySQL}, even if these install the server in slightly different
+locations. @code{safe_mysqld} expects one of these conditions to be true:
+
+@itemize @bullet
@item
-If you make changes to the grant tables directly (using an @code{INSERT} or
-@code{UPDATE} statement) and your changes seem to be ignored, remember
-that you must issue a @code{FLUSH PRIVILEGES} statement or execute a
-@code{mysqladmin flush-privileges} command to cause the server to re-read
-the privilege tables. Otherwise your changes have no effect until the
-next time the server is restarted. Remember that after you set the
-@code{root} password with an @code{UPDATE} command, you won't need to
-specify it until after you flush the privileges, because the server
-won't know you've changed the password yet!
+The server and databases can be found relative to the directory from which
+@code{safe_mysqld} is invoked. @code{safe_mysqld} looks under its working
+directory for @file{bin} and @file{data} directories (for binary
+distributions) or for @file{libexec} and @file{var} directories (for source
+distributions). This condition should be met if you execute
+@code{safe_mysqld} from your @strong{MySQL} installation directory (for
+example, @file{/usr/local/mysql} for a binary distribution).
@item
-If you have access problems with a Perl, PHP, Python, or ODBC program, try to
-connect to the server with @code{mysql -u user_name db_name} or @code{mysql
--u user_name -pyour_pass db_name}. If you are able to connect using the
-@code{mysql} client, there is a problem with your program and not with the
-access privileges. (Note that there is no space between @code{-p} and the
-password; you can also use the @code{--password=your_pass} syntax to specify
-the password. If you use the @code{-p} option alone, @strong{MySQL} will
-prompt you for the password.)
+If the server and databases cannot be found relative to the working directory,
+@code{safe_mysqld} attempts to locate them by absolute pathnames. Typical
+locations are @file{/usr/local/libexec} and @file{/usr/local/var}.
+The actual locations are determined when the distribution was built from which
+@code{safe_mysqld} comes. They should be correct if
+@strong{MySQL} was installed in a standard location.
+@end itemize
+Because @code{safe_mysqld} will try to find the server and databases relative
+to its own working directory, you can install a binary distribution of
+@strong{MySQL} anywhere, as long as you start @code{safe_mysqld} from the
+@strong{MySQL} installation directory:
+
+@example
+shell> cd mysql_installation_directory
+shell> bin/safe_mysqld &
+@end example
+
+If @code{safe_mysqld} fails, even when invoked from the @strong{MySQL}
+installation directory, you can modify it to use the path to @code{mysqld}
+and the pathname options that are correct for your system. Note that if you
+upgrade @strong{MySQL} in the future, your modified version of
+@code{safe_mysqld} will be overwritten, so you should make a copy of your
+edited version that you can reinstall.
+
+
+@node mysqld_multi, myisampack, safe_mysqld, Server-Side Scripts
+@subsection mysqld_multi, program for managing multiple @strong{MySQL} servers
+
+@cindex tools, mysqld_multi
+@cindex scripts
+@cindex multi mysqld
+@cindex @code{mysqld_multi}
+
+@code{mysqld_multi} is meant for managing several @code{mysqld}
+processes running in different UNIX sockets and TCP/IP ports.
+
+The program will search for group(s) named [mysqld#] from my.cnf (or the
+given --config-file=...), where # can be any positive number starting
+from 1. These groups should be the same as the usual @code{[mysqld]}
+group (e.g. options to mysqld, see @strong{MySQL} manual for detailed
+information about this group), but with those port, socket etc. options
+that are wanted for each separate @code{mysqld} processes. The number in
+the group name has another function; it can be used for starting,
+stopping, or reporting some specific @code{mysqld} servers with this
+program. See the usage and options below for more information.
+
+@example
+Usage: mysqld_multi [OPTIONS] @{start|stop|report@} [GNR,GNR,GNR...]
+or mysqld_multi [OPTIONS] @{start|stop|report@} [GNR-GNR,GNR,GNR-GNR,...]
+@end example
+
+The GNR above means the group number. You can start, stop or report
+any GNR, or several of them at the same time. (See --example) The GNRs
+list can be comma separated, or a dash combined, of which the latter
+means that all the GNRs between GNR1-GNR2 will be affected. Without
+GNR argument all the found groups will be either started, stopped, or
+reported. Note that you must not have any white spaces in the GNR
+list. Anything after a white space is ignored.
+
+@code{mysqld_multi} supports the following options:
+
+@table @code
+@cindex config-file option
+@item --config-file=...
+Alternative config file. NOTE: This will not affect this program's own
+options (group @code{[mysqld_multi]}), but only groups
+[mysqld#]. Without this option everything will be searched from the
+ordinary my.cnf file.
+@cindex example option
+@item --example
+Give an example of a config file.
+@cindex help option
+@item --help
+Print this help and exit.
+@cindex log option
+@item --log=...
+Log file. Full path to and the name for the log file. NOTE: If the file
+exists, everything will be appended.
+@cindex mysqladmin option
+@item --mysqladmin=...
+@code{mysqladmin} binary to be used for a server shutdown.
+@cindex mysqld option
+@item --mysqld=...
+@code{mysqld} binary to be used. Note that you can give
+@code{safe_mysqld} to this option also. The options are passed to
+@code{mysqld}. Just make sure you have @code{mysqld} in your environment
+variable @code{PATH} or fix @code{safe_mysqld}.
+@cindex no-log option
+@item --no-log
+Print to stdout instead of the log file. By default the log file is
+turned on.
+@cindex password option
+@item --password=...
+Password for user for @code{mysqladmin}.
+@cindex tcp-ip option
+@item --tcp-ip
+Connect to the @strong{MySQL} server(s) via the TCP/IP port instead of
+the UNIX socket. This affects stopping and reporting. If a socket file
+is missing, the server may still be running, but can be accessed only
+via the TCP/IP port. By default connecting is done via the UNIX socket.
+@cindex user option
+@item --user=...
+@strong{MySQL} user for @code{mysqladmin}.
+@cindex version option
+@item --version
+Print the version number and exit.
+@end table
+
+Some notes about @code{mysqld_multi}:
+
+@itemize @bullet
@item
-For testing, start the @code{mysqld} daemon with the
-@code{--skip-grant-tables} option. Then you can change the @strong{MySQL}
-grant tables and use the @code{mysqlaccess} script to check whether or not
-your modifications have the desired effect. When you are satisfied with your
-changes, execute @code{mysqladmin flush-privileges} to tell the @code{mysqld}
-server to start using the new grant tables. @strong{Note:} Reloading the
-grant tables overrides the @code{--skip-grant-tables} option. This allows
-you to tell the server to begin using the grant tables again without bringing
-it down and restarting it.
+Make sure that the @strong{MySQL} user, who is stopping the
+@code{mysqld} services (e.g using the @code{mysqladmin}) have the same
+password and username for all the data directories accessed (to the
+'mysql' database) And make sure that the user has the 'Shutdown_priv'
+privilege! If you have many data- directories and many different 'mysql'
+databases with different passwords for the @strong{MySQL} 'root' user,
+you may want to create a common 'multi_admin' user for each using the
+same password (see below). Example how to do it:
+@example
+shell> mysql -u root -S /tmp/mysql.sock -proot_password -e
+"GRANT SHUTDOWN ON *.* TO multi_admin@@localhost IDENTIFIED BY 'multipass'"
+@xref{Privileges}.
+@end example
+You will have to do the above for each @code{mysqld} running in each
+data directory, that you have (just change the socket, -S=...)
+@item
+@code{pid-file} is very important, if you are using @code{safe_mysqld}
+to start @code{mysqld} (e.g. --mysqld=safe_mysqld) Every @code{mysqld}
+should have its own @code{pid-file}. The advantage using
+@code{safe_mysqld} instead of @code{mysqld} directly here is, that
+@code{safe_mysqld} 'guards' every @code{mysqld} process and will restart
+it, if a @code{mysqld} process fails due to signal kill -9, or
+similar. (Like segmentation fault, which @strong{MySQL} should never do,
+of course ;) Please note that @code{safe_mysqld} script may require that
+you start it from a certain place. This means that you may have to CD to
+a certain directory, before you start the @code{mysqld_multi}. If
+you have problems starting, please see the @code{safe_mysqld}
+script. Check especially the lines:
+@example
+--------------------------------------------------------------------------
+MY_PWD=`pwd` Check if we are starting this relative (for the binary
+release) if test -d /data/mysql -a -f ./share/mysql/english/errmsg.sys
+-a -x ./bin/mysqld
+--------------------------------------------------------------------------
+@xref{safe_mysqld, , @code{safe_mysqld}}.
+@end example
+The above test should be successful, or you may encounter problems.
+@item
+Beware of the dangers starting multiple @code{mysqlds} in the same data
+directory. Use separate data directories, unless you @strong{KNOW} what
+you are doing!
+@item
+The socket file and the TCP/IP port must be different for every @code{mysqld}.
+@item
+The first and fifth @code{mysqld} group were intentionally left out from
+the example. You may have 'gaps' in the config file. This gives you
+more flexibility. The order in which the @code{mysqlds} are started or
+stopped depends on the order in which they appear in the config file.
+@item
+When you want to refer to a certain group using GNR with this program,
+just use the number in the end of the group name ( [mysqld# <== ).
+@item
+You may want to use option '--user' for @code{mysqld}, but in order to
+do this you need to be root when you start the @code{mysqld_multi}
+script. Having the option in the config file doesn't matter; you will
+just get a warning, if you are not the superuser and the @code{mysqlds}
+are started under @strong{YOUR} UNIX account. @strong{IMPORTANT}: Make
+sure that the @code{pid-file} and the data directory are
+read+write(+execute for the latter one) accessible for @strong{THAT}
+UNIX user, who the specific @code{mysqld} process is started
+as. @strong{DON'T} use the UNIX root account for this, unless you
+@strong{KNOW} what you are doing!
+@item
+@strong{MOST IMPORTANT}: Make sure that you understand the meanings of
+the options that are passed to the @code{mysqlds} and why @strong{WOULD
+YOU WANT} to have separate @code{mysqld} processes. Starting multiple
+@code{mysqlds} in one data directory @strong{WILL NOT} give you extra
+performance in a threaded system!
+@end itemize
+
+@xref{Multiple servers}.
+
+This is an example of the config file on behalf of @code{mysqld_multi}.
+
+@example
+# This file should probably be in your home dir (~/.my.cnf) or /etc/my.cnf
+# Version 2.1 by Jani Tolonen
+[mysqld_multi]
+mysqld = /usr/local/bin/safe_mysqld
+mysqladmin = /usr/local/bin/mysqladmin
+user = multi_admin
+password = multipass
+
+[mysqld2]
+socket = /tmp/mysql.sock2
+port = 3307
+pid-file = /usr/local/mysql/var2/hostname.pid2
+datadir = /usr/local/mysql/var2
+language = /usr/local/share/mysql/english
+user = john
+
+[mysqld3]
+socket = /tmp/mysql.sock3
+port = 3308
+pid-file = /usr/local/mysql/var3/hostname.pid3
+datadir = /usr/local/mysql/var3
+language = /usr/local/share/mysql/swedish
+user = monty
+
+[mysqld4]
+socket = /tmp/mysql.sock4
+port = 3309
+pid-file = /usr/local/mysql/var4/hostname.pid4
+datadir = /usr/local/mysql/var4
+language = /usr/local/share/mysql/estonia
+user = tonu
+
+[mysqld6]
+socket = /tmp/mysql.sock6
+port = 3311
+pid-file = /usr/local/mysql/var6/hostname.pid6
+datadir = /usr/local/mysql/var6
+language = /usr/local/share/mysql/japanese
+user = jani
+@end example
+
+@xref{Option files}.
+
+
+@node myisampack, mysqld-max, mysqld_multi, Server-Side Scripts
+@subsection myisampack, The MySQL Compressed Read-only Table Generator
+
+@cindex compressed tables
+@cindex tables, compressed
+@cindex MyISAM, compressed tables
+@cindex @code{myisampack}
+@cindex @code{pack_isam}
+
+@code{myisampack} is used to compress MyISAM tables, and @code{pack_isam}
+is used to compress ISAM tables. Because ISAM tables are deprecated, we
+will only discuss @code{myisampack} here, but everything said about
+@code{myisampack} should also be true for @code{pack_isam}.
+
+@code{myisampack} works by compressing each column in the table separately.
+The information needed to decompress columns is read into memory when the
+table is opened. This results in much better performance when accessing
+individual records, because you only have to uncompress exactly one record, not
+a much larger disk block as when using Stacker on MS-DOS.
+Usually, @code{myisampack} packs the data file 40%-70%.
+
+@strong{MySQL} uses memory mapping (@code{mmap()}) on compressed tables and
+falls back to normal read/write file usage if @code{mmap()} doesn't work.
+
+There are currently two limitations with @code{myisampack}:
+@itemize @bullet
@item
-If everything else fails, start the @code{mysqld} daemon with a debugging
-option (for example, @code{--debug=d,general,query}). This will print host and
-user information about attempted connections, as well as information about
-each command issued. @xref{Making trace files}.
+After packing, the table is read-only.
+@item
+@code{myisampack} can also pack @code{BLOB} or @code{TEXT} columns. The
+older @code{pack_isam} could not do this.
+@end itemize
+
+Fixing these limitations is on our TODO list but with low priority.
+
+@code{myisampack} is invoked like this:
+
+@example
+shell> myisampack [options] filename ...
+@end example
+
+Each filename should be the name of an index (@file{.MYI}) file. If you
+are not in the database directory, you should specify the pathname to the
+file. It is permissible to omit the @file{.MYI} extension.
+
+@code{myisampack} supports the following options:
+
+@table @code
+@item -b, --backup
+Make a backup of the table as @code{tbl_name.OLD}.
+
+@item -#, --debug=debug_options
+Output debug log. The @code{debug_options} string often is
+@code{'d:t:o,filename'}.
+
+@item -f, --force
+Force packing of the table even if it becomes bigger or if the temporary file
+exists. @code{myisampack} creates a temporary file named @file{tbl_name.TMD}
+while it compresses the table. If you kill @code{myisampack}, the @file{.TMD}
+file may not be deleted. Normally, @code{myisampack} exits with an error if
+it finds that @file{tbl_name.TMD} exists. With @code{--force},
+@code{myisampack} packs the table anyway.
+
+@item -?, --help
+Display a help message and exit.
+
+@item -j big_tbl_name, --join=big_tbl_name
+Join all tables named on the command line into a single table
+@code{big_tbl_name}. All tables that are to be combined
+MUST be identical (same column names and types, same indexes, etc.).
+
+@item -p #, --packlength=#
+Specify the record length storage size, in bytes. The value should be 1, 2,
+or 3. (@code{myisampack} stores all rows with length pointers of 1, 2, or 3
+bytes. In most normal cases, @code{myisampack} can determine the right length
+value before it begins packing the file, but it may notice during the packing
+process that it could have used a shorter length. In this case,
+@code{myisampack} will print a note that the next time you pack the same file,
+you could use a shorter record length.)
+
+@item -s, --silent
+Silent mode. Write output only when errors occur.
+
+@item -t, --test
+Don't actually pack table, just test packing it.
+
+@item -T dir_name, --tmp_dir=dir_name
+Use the named directory as the location in which to write the temporary table.
+
+@item -v, --verbose
+Verbose mode. Write information about progress and packing result.
+
+@item -V, --version
+Display version information and exit.
+
+@item -w, --wait
+
+Wait and retry if table is in use. If the @code{mysqld} server was
+invoked with the @code{--skip-locking} option, it is not a good idea to
+invoke @code{myisampack} if the table might be updated during the
+packing process.
+@end table
+
+@cindex examples, compressed tables
+The sequence of commands shown below illustrates a typical table compression
+session:
+
+@example
+shell> ls -l station.*
+-rw-rw-r-- 1 monty my 994128 Apr 17 19:00 station.MYD
+-rw-rw-r-- 1 monty my 53248 Apr 17 19:00 station.MYI
+-rw-rw-r-- 1 monty my 5767 Apr 17 19:00 station.frm
+
+shell> myisamchk -dvv station
+
+MyISAM file: station
+Isam-version: 2
+Creation time: 1996-03-13 10:08:58
+Recover time: 1997-02-02 3:06:43
+Data records: 1192 Deleted blocks: 0
+Datafile: Parts: 1192 Deleted data: 0
+Datafile pointer (bytes): 2 Keyfile pointer (bytes): 2
+Max datafile length: 54657023 Max keyfile length: 33554431
+Recordlength: 834
+Record format: Fixed length
+
+table description:
+Key Start Len Index Type Root Blocksize Rec/key
+1 2 4 unique unsigned long 1024 1024 1
+2 32 30 multip. text 10240 1024 1
+
+Field Start Length Type
+1 1 1
+2 2 4
+3 6 4
+4 10 1
+5 11 20
+6 31 1
+7 32 30
+8 62 35
+9 97 35
+10 132 35
+11 167 4
+12 171 16
+13 187 35
+14 222 4
+15 226 16
+16 242 20
+17 262 20
+18 282 20
+19 302 30
+20 332 4
+21 336 4
+22 340 1
+23 341 8
+24 349 8
+25 357 8
+26 365 2
+27 367 2
+28 369 4
+29 373 4
+30 377 1
+31 378 2
+32 380 8
+33 388 4
+34 392 4
+35 396 4
+36 400 4
+37 404 1
+38 405 4
+39 409 4
+40 413 4
+41 417 4
+42 421 4
+43 425 4
+44 429 20
+45 449 30
+46 479 1
+47 480 1
+48 481 79
+49 560 79
+50 639 79
+51 718 79
+52 797 8
+53 805 1
+54 806 1
+55 807 20
+56 827 4
+57 831 4
+
+shell> myisampack station.MYI
+Compressing station.MYI: (1192 records)
+- Calculating statistics
+
+normal: 20 empty-space: 16 empty-zero: 12 empty-fill: 11
+pre-space: 0 end-space: 12 table-lookups: 5 zero: 7
+Original trees: 57 After join: 17
+- Compressing file
+87.14%
+
+shell> ls -l station.*
+-rw-rw-r-- 1 monty my 127874 Apr 17 19:00 station.MYD
+-rw-rw-r-- 1 monty my 55296 Apr 17 19:04 station.MYI
+-rw-rw-r-- 1 monty my 5767 Apr 17 19:00 station.frm
+
+shell> myisamchk -dvv station
+
+MyISAM file: station
+Isam-version: 2
+Creation time: 1996-03-13 10:08:58
+Recover time: 1997-04-17 19:04:26
+Data records: 1192 Deleted blocks: 0
+Datafile: Parts: 1192 Deleted data: 0
+Datafilepointer (bytes): 3 Keyfile pointer (bytes): 1
+Max datafile length: 16777215 Max keyfile length: 131071
+Recordlength: 834
+Record format: Compressed
+
+table description:
+Key Start Len Index Type Root Blocksize Rec/key
+1 2 4 unique unsigned long 10240 1024 1
+2 32 30 multip. text 54272 1024 1
+
+Field Start Length Type Huff tree Bits
+1 1 1 constant 1 0
+2 2 4 zerofill(1) 2 9
+3 6 4 no zeros, zerofill(1) 2 9
+4 10 1 3 9
+5 11 20 table-lookup 4 0
+6 31 1 3 9
+7 32 30 no endspace, not_always 5 9
+8 62 35 no endspace, not_always, no empty 6 9
+9 97 35 no empty 7 9
+10 132 35 no endspace, not_always, no empty 6 9
+11 167 4 zerofill(1) 2 9
+12 171 16 no endspace, not_always, no empty 5 9
+13 187 35 no endspace, not_always, no empty 6 9
+14 222 4 zerofill(1) 2 9
+15 226 16 no endspace, not_always, no empty 5 9
+16 242 20 no endspace, not_always 8 9
+17 262 20 no endspace, no empty 8 9
+18 282 20 no endspace, no empty 5 9
+19 302 30 no endspace, no empty 6 9
+20 332 4 always zero 2 9
+21 336 4 always zero 2 9
+22 340 1 3 9
+23 341 8 table-lookup 9 0
+24 349 8 table-lookup 10 0
+25 357 8 always zero 2 9
+26 365 2 2 9
+27 367 2 no zeros, zerofill(1) 2 9
+28 369 4 no zeros, zerofill(1) 2 9
+29 373 4 table-lookup 11 0
+30 377 1 3 9
+31 378 2 no zeros, zerofill(1) 2 9
+32 380 8 no zeros 2 9
+33 388 4 always zero 2 9
+34 392 4 table-lookup 12 0
+35 396 4 no zeros, zerofill(1) 13 9
+36 400 4 no zeros, zerofill(1) 2 9
+37 404 1 2 9
+38 405 4 no zeros 2 9
+39 409 4 always zero 2 9
+40 413 4 no zeros 2 9
+41 417 4 always zero 2 9
+42 421 4 no zeros 2 9
+43 425 4 always zero 2 9
+44 429 20 no empty 3 9
+45 449 30 no empty 3 9
+46 479 1 14 4
+47 480 1 14 4
+48 481 79 no endspace, no empty 15 9
+49 560 79 no empty 2 9
+50 639 79 no empty 2 9
+51 718 79 no endspace 16 9
+52 797 8 no empty 2 9
+53 805 1 17 1
+54 806 1 3 9
+55 807 20 no empty 3 9
+56 827 4 no zeros, zerofill(2) 2 9
+57 831 4 no zeros, zerofill(1) 2 9
+@end example
+
+The information printed by @code{myisampack} is described below:
+
+@table @code
+@item normal
+The number of columns for which no extra packing is used.
+
+@item empty-space
+The number of columns containing
+values that are only spaces; these will occupy 1 bit.
+
+@item empty-zero
+The number of columns containing
+values that are only binary 0's; these will occupy 1 bit.
+
+@item empty-fill
+The number of integer columns that don't occupy the full byte range of their
+type; these are changed to a smaller type (for example, an @code{INTEGER}
+column may be changed to @code{MEDIUMINT}).
+
+@item pre-space
+The number of decimal columns that are stored with leading spaces. In this
+case, each value will contain a count for the number of leading spaces.
+
+@item end-space
+The number of columns that have a lot of trailing spaces. In this case, each
+value will contain a count for the number of trailing spaces.
+
+@item table-lookup
+The column had only a small number of different values, which were
+converted to an @code{ENUM} before Huffman compression.
+
+@item zero
+The number of columns for which all values are zero.
+
+@item Original trees
+The initial number of Huffman trees.
+
+@item After join
+The number of distinct Huffman trees left after joining
+trees to save some header space.
+@end table
+
+After a table has been compressed, @code{myisamchk -dvv} prints additional
+information about each field:
+
+@table @code
+@item Type
+The field type may contain the following descriptors:
+
+@table @code
+@item constant
+All rows have the same value.
+
+@item no endspace
+Don't store endspace.
+
+@item no endspace, not_always
+Don't store endspace and don't do end space compression for all values.
+
+@item no endspace, no empty
+Don't store endspace. Don't store empty values.
+
+@item table-lookup
+The column was converted to an @code{ENUM}.
+
+@item zerofill(n)
+The most significant @code{n} bytes in the value are always 0 and are not
+stored.
+
+@item no zeros
+Don't store zeros.
+
+@item always zero
+0 values are stored in 1 bit.
+@end table
+
+@item Huff tree
+The Huffman tree associated with the field.
+
+@item Bits
+The number of bits used in the Huffman tree.
+@end table
+
+After you have run @code{pack_isam}/@code{myisampack} you must run
+@code{isamchk}/@code{myisamchk} to re-create the index. At this time you
+can also sort the index blocks and create statistics needed for
+the @strong{MySQL} optimizer to work more efficiently:
+
+@example
+myisamchk -rq --analyze --sort-index table_name.MYI
+isamchk -rq --analyze --sort-index table_name.ISM
+@end example
+
+After you have installed the packed table into the @strong{MySQL} database
+directory you should do @code{mysqladmin flush-tables} to force @code{mysqld}
+to start using the new table.
+
+If you want to unpack a packed table, you can do this with the
+@code{--unpack} option to @code{isamchk} or @code{myisamchk}.
+
+
+@node mysqld-max, , myisampack, Server-Side Scripts
+@subsection mysqld-max, An extended mysqld server
+
+@cindex @code{mysqld-max}
+
+@code{mysqld-max} is the MySQL server (@code{mysqld}) configured with
+the following configure options:
+
+@multitable @columnfractions .3 .7
+@item @strong{Option} @tab @strong{Comment}
+@item --with-server-suffix=-max @tab Add a suffix to the @code{mysqld} version string.
+@item --with-bdb @tab Support for Berkeley DB (BDB) tables
+@item --with-innodb @tab Support for InnoDB tables.
+@item CFLAGS=-DUSE_SYMDIR @tab Symbolic links support for Windows.
+@end multitable
+
+You can find the @strong{MySQL}-max binaries at
+@uref{http://www.mysql.com/downloads/mysql-max-3.23.html}.
+
+The Windows @strong{MySQL} 3.23 binary distribution includes both the
+standard @strong{mysqld.exe} binary and the @code{mysqld-max.exe} binary.
+@uref{http://www.mysql.com/downloads/mysql-3.23.html}.
+@xref{Windows installation}.
+
+Note that as Berkeley DB and InnoDB are not available for all platforms,
+some of the @code{Max} binaries may not have support for both of these.
+You can check which table types are supported by doing the following
+query:
+
+@example
+mysql> show variables like "have_%";
++---------------+-------+
+| Variable_name | Value |
++---------------+-------+
+| have_bdb | YES |
+| have_innodb | NO |
+| have_isam | YES |
+| have_raid | YES |
+| have_ssl | NO |
++---------------+-------+
+@end example
+
+The meaning of the values are:
+
+@multitable @columnfractions .3 .7
+@item @strong{Value} @tab @strong{Meaning}.
+@item YES @tab The option is activated and usable.
+@item NO @tab @strong{MySQL} is not compiled with support for this option.
+@item DISABLED @tab The xxxx option is disabled because one started @code{mysqld} with @code{--skip-xxxx} or because one didn't start @code{mysqld} with all needed options to enable the option. In this case the @code{hostname.err} file should contain a reason for why the option is disabled.
+@end multitable
+
+@strong{NOTE}: To be able to create InnoDB tables you @strong{MUST} edit
+your startup options to include at least the @code{innodb_data_file_path}
+option. @xref{InnoDB start}.
+
+To get better performance for BDB tables, you should add some configuration
+options for these too. @xref{BDB start}.
+
+@code{safe_mysqld} will automatically try to start any @code{mysqld} binary
+with the @code{-max} prefix. This makes it very easy to test out a
+another @code{mysqld} binary in an existing installation. Just
+run @code{configure} with the options you want and then install the
+new @code{mysqld} binary as @code{mysqld-max} in the same directory
+where your old @code{mysqld} binary is. @xref{safe_mysqld, , @code{safe_mysqld}}.
+
+The @code{mysqld-max} RPM uses the above mentioned @code{safe_mysqld}
+feature. It just installs the @code{mysqld-max} executable and
+@code{safe_mysqld} will automatically use this executable when
+@code{safe_mysqld} is restarted.
+
+The following table shows which table types our standard @strong{MySQL-Max}
+binaries includes:
+
+@multitable @columnfractions .4 .3 .3
+@item @strong{System} @tab @strong{BDB} @tab @strong{InnoDB}
+@item AIX 4.3 @tab N @tab Y
+@item HP-UX 11.0 @tab N @tab Y
+@item Linux-Alpha @tab N @tab Y
+@item Linux-Intel @tab Y @tab Y
+@item Linux-Ia64 @tab N @tab Y
+@item Solaris-intel @tab N @tab Y
+@item Solaris-sparc @tab Y @tab Y
+@item SCO OSR5 @tab Y @tab Y
+@item UnixWare @tab Y @tab Y
+@item Windows/NT @tab Y @tab Y
+@end multitable
+
+
+@node Client-Side Scripts, perror, Server-Side Scripts, MySQL Database Administration
+@section MySQL Client-Side Scripts and Utilities
+
+@menu
+* Client-Side Overview::
+* mysql::
+* mysqladmin::
+* mysqldump::
+* mysqlhotcopy::
+* mysqlimport::
+* mysqlshow::
+@end menu
+
+
+@node Client-Side Overview, mysql, Client-Side Scripts, Client-Side Scripts
+@subsection Overview of the Client-Side Scripts and Utilities
+
+@cindex environment variables
+@cindex programs, list of
+
+All @strong{MySQL} clients that communicate with the server using the
+@code{mysqlclient} library use the following environment variables:
+
+@tindex MYSQL_UNIX_PORT environment variable
+@tindex Environment variable, MYSQL_UNIX_PORT
+@tindex MYSQL_TCP_PORT environment variable
+@tindex Environment variable, MYSQL_TCP_PORT
+@tindex MYSQL_PWD environment variable
+@tindex Environment variable, MYSQL_PWD
+@tindex MYSQL_DEBUG environment variable
+@tindex Environment variable, MYSQL_DEBUG
+@multitable @columnfractions .25 .75
+@item @strong{Name} @tab @strong{Description}
+@item @code{MYSQL_UNIX_PORT} @tab The default socket; used for connections to @code{localhost}
+@item @code{MYSQL_TCP_PORT} @tab The default TCP/IP port
+@item @code{MYSQL_PWD} @tab The default password
+@item @code{MYSQL_DEBUG} @tab Debug-trace options when debugging
+@item @code{TMPDIR} @tab The directory where temporary tables/files are created
+@end multitable
+
+Use of @code{MYSQL_PWD} is insecure.
+@xref{Connecting}.
+
+@tindex MYSQL_HISTFILE environment variable
+@tindex Environment variable, MYSQL_HISTFILE
+@tindex HOME environment variable
+@tindex Environment variable, HOME
+@cindex history file
+@cindex command line history
+@tindex .mysql_history file
+The @file{mysql} client uses the file named in the @code{MYSQL_HISTFILE}
+environment variable to save the command-line history. The default value for
+the history file is @file{$HOME/.mysql_history}, where @code{$HOME} is the
+value of the @code{HOME} environment variable. @xref{Environment variables}.
+
+All @strong{MySQL} programs take many different options. However, every
+@strong{MySQL} program provides a @code{--help} option that you can use
+to get a full description of the program's different options. For example, try
+@code{mysql --help}.
+
+You can override default options for all standard client programs with an
+option file. @ref{Option files}.
+
+The list below briefly describes the @strong{MySQL} programs:
+
+@table @code
+
+@cindex @code{myisamchk}
+@item myisamchk
+Utility to describe, check, optimize, and repair @strong{MySQL} tables.
+Because @code{myisamchk} has many functions, it is described in its own
+chapter. @xref{Maintenance}.
+
+@cindex @code{make_binary_distribution}
+@item make_binary_distribution
+Makes a binary release of a compiled @strong{MySQL}. This could be sent
+by FTP to @file{/pub/mysql/Incoming} on @code{support.mysql.com} for the
+convenience of other @strong{MySQL} users.
+
+@cindex @code{msql2mysql}
+@item msql2mysql
+A shell script that converts @code{mSQL} programs to @strong{MySQL}. It doesn't
+handle all cases, but it gives a good start when converting.
+
+@cindex @code{mysqlaccess}
+@item mysqlaccess
+A script that checks the access privileges for a host, user, and database
+combination.
+
+@cindex @code{mysqladmin}
+@item mysqladmin
+Utility for performing administrative operations, such as creating or
+dropping databases, reloading the grant tables, flushing tables to disk, and
+reopening log files. @code{mysqladmin} can also be used to retrieve version,
+process, and status information from the server.
+@xref{mysqladmin, , @code{mysqladmin}}.
+
+@cindex @code{mysqlbug}
+@item mysqlbug
+The @strong{MySQL} bug report script. This script should always be used when
+filing a bug report to the @strong{MySQL} list.
+
+@cindex @code{mysqld}
+@item mysqld
+The SQL daemon. This should always be running.
+
+@cindex @code{mysqldump}
+@item mysqldump
+Dumps a @strong{MySQL} database into a file as SQL statements or
+as tab-separated text files. Enhanced freeware originally by Igor Romanenko.
+@xref{mysqldump, , @code{mysqldump}}.
+
+@cindex @code{mysqlimport}
+@item mysqlimport
+Imports text files into their respective tables using @code{LOAD DATA
+INFILE}. @xref{mysqlimport, , @code{mysqlimport}}.
+
+@cindex @code{mysqlshow}
+@item mysqlshow
+Displays information about databases, tables, columns, and indexes.
+
+@cindex @code{mysql_install_db}
+@item mysql_install_db
+Creates the @strong{MySQL} grant tables with default privileges. This is
+usually executed only once, when first installing @strong{MySQL}
+on a system.
+
+@cindex @code{replace}
+@item replace
+A utility program that is used by @code{msql2mysql}, but that has more
+general applicability as well. @code{replace} changes strings in place in
+files or on the standard input. Uses a finite state machine to match longer
+strings first. Can be used to swap strings. For example, this command
+swaps @code{a} and @code{b} in the given files:
+
+@example
+shell> replace a b b a -- file1 file2 ...
+@end example
+@end table
+
+
+@node mysql, mysqladmin, Client-Side Overview, Client-Side Scripts
+@subsection The Command-line Tool
+
+@cindex command line tool
+@cindex tools, command line
+@cindex scripts
+@cindex @code{mysql}
+
+@code{mysql} is a simple SQL shell (with GNU @code{readline} capabilities).
+It supports interactive and non-interactive use. When used interactively,
+query results are presented in an ASCII-table format. When used
+non-interactively (for example, as a filter), the result is presented in
+tab-separated format. (The output format can be changed using command-line
+options.) You can run scripts simply like this:
+
+@example
+shell> mysql database < script.sql > output.tab
+@end example
+
+If you have problems due to insufficient memory in the client, use the
+@code{--quick} option! This forces @code{mysql} to use
+@code{mysql_use_result()} rather than @code{mysql_store_result()} to
+retrieve the result set.
+
+Using @code{mysql} is very easy. Just start it as follows:
+@code{mysql database} or @code{mysql --user=user_name --password=your_password database}. Type a SQL statement, end it with @samp{;}, @samp{\g}, or @samp{\G}
+and press RETURN/ENTER.
+
+@cindex command line options
+@cindex options, command line
+@cindex startup parameters
+@code{mysql} supports the following options:
+
+@table @code
+@cindex help option
+@item -?, --help
+Display this help and exit.
+@cindex automatic rehash option
+@item -A, --no-auto-rehash
+No automatic rehashing. One has to use 'rehash' to get table and field
+completion. This gives a quicker start of mysql.
+@cindex batch option
+@item -B, --batch
+Print results with a tab as separator, each row on a new line. Doesn't use
+history file.
+@cindex character sets option
+@item --character-sets-dir=...
+Directory where character sets are located.
+@cindex compress option.
+@item -C, --compress
+Use compression in server/client protocol.
+@cindex debug option
+@item -#, --debug[=...]
+Debug log. Default is 'd:t:o,/tmp/mysql.trace'.
+@cindex database option
+@item -D, --database=...
+Database to use. This is mainly useful in the @code{my.cnf} file.
+@cindex default character set option
+@item --default-character-set=...
+Set the default character set.
+@cindex execute option
+@item -e, --execute=...
+Execute command and quit. (Output like with --batch)
+@cindex vertical option
+@item -E, --vertical
+Print the output of a query (rows) vertically. Without this option you
+can also force this output by ending your statements with @code{\G}.
+@cindex force option
+@item -f, --force
+Continue even if we get a SQL error.
+@cindex no-named-commands option
+@item -g, --no-named-commands
+Named commands are disabled. Use \* form only, or use named commands
+only in the beginning of a line ending with a semicolon (;). Since
+Version 10.9, the client now starts with this option ENABLED by default!
+With the -g option, long format commands will still work from the first
+line, however.
+@cindex enable-named-commands option
+@item -G, --enable-named-commands
+Named commands are @strong{enabled}. Long format commands are allowed as
+well as shortened \* commands.
+@cindex ignore space option.
+@item -i, --ignore-space
+Ignore space after function names.
+@cindex host option
+@item -h, --host=...
+Connect to the given host.
+@cindex html option
+@item -H, --html
+Produce HTML output.
+@cindex skip line numbers option
+@item -L, --skip-line-numbers
+Don't write line number for errors. Useful when one wants to compare result
+files that includes error messages
+@cindex no pager option
+@item --no-pager
+Disable pager and print to stdout. See interactive help (\h) also.
+@cindex no tee option
+@item --no-tee
+Disable outfile. See interactive help (\h) also.
+@cindex unbuffered option.
+@item -n, --unbuffered
+Flush buffer after each query.
+@cindex skip column names option
+@item -N, --skip-column-names
+Don't write column names in results.
+@cindex set variable option
+@item -O, --set-variable var=option
+Give a variable a value. @code{--help} lists variables.
+@cindex one database option
+@item -o, --one-database
+Only update the default database. This is useful for skipping updates to
+other database in the update log.
+@cindex pager option
+@item @code{--pager[=...]}
+Output type. Default is your @code{ENV} variable @code{PAGER}. Valid
+pagers are less, more, cat [> filename], etc. See interactive help (\h)
+also. This option does not work in batch mode. Pager works only in UNIX.
+@cindex password option
+@item -p[password], --password[=...]
+Password to use when connecting to server. If a password is not given on
+the command line, you will be prompted for it. Note that if you use the
+short form @code{-p} you can't have a space between the option and the
+password.
+@item -P --port=...
+TCP/IP port number to use for connection.
+@cindex quick option
+@item -q, --quick
+Don't cache result, print it row-by-row. This may slow down the server
+if the output is suspended. Doesn't use history file.
+@cindex raw option
+@item -r, --raw
+Write column values without escape conversion. Used with @code{--batch}
+@cindex silent option
+@item -s, --silent
+Be more silent.
+@item -S --socket=...
+Socket file to use for connection.
+@cindex table option
+@item -t --table
+Output in table format. This is default in non-batch mode.
+@item -T, --debug-info
+Print some debug information at exit.
+@cindex tee option
+@item --tee=...
+Append everything into outfile. See interactive help (\h) also. Does not
+work in batch mode.
+@cindex user option
+@item -u, --user=#
+User for login if not current user.
+@cindex safe updates option
+@item -U, --safe-updates[=#], --i-am-a-dummy[=#]
+Only allow @code{UPDATE} and @code{DELETE} that uses keys. See below for
+more information about this option. You can reset this option if you have
+it in your @code{my.cnf} file by using @code{--safe-updates=0}.
+@cindex verbose option
+@item -v, --verbose
+More verbose output (-v -v -v gives the table output format).
+@cindex version option
+@item -V, --version
+Output version information and exit.
+@cindex wait option
+@item -w, --wait
+Wait and retry if connection is down instead of aborting.
+@end table
+
+You can also set the following variables with @code{-O} or
+@code{--set-variable}:
+
+@cindex timeout
+@multitable @columnfractions .3 .2 .5
+@item Variablename @tab Default @tab Description
+@item connect_timeout @tab 0 @tab Number of seconds before timeout connection.
+@item max_allowed_packet @tab 16777216 @tab Max packetlength to send/receive from to server
+@item net_buffer_length @tab 16384 @tab Buffer for TCP/IP and socket communication
+@item select_limit @tab 1000 @tab Automatic limit for SELECT when using --i-am-a-dummy
+@item max_join_size @tab 1000000 @tab Automatic limit for rows in a join when using --i-am-a-dummy.
+@end multitable
+
+If you type 'help' on the command line, @code{mysql} will print out the
+commands that it supports:
+@cindex commands, list of
+@example
+mysql> help
+
+MySQL commands:
+help (\h) Display this text.
+? (\h) Synonym for `help'.
+clear (\c) Clear command.
+connect (\r) Reconnect to the server. Optional arguments are db and host.
+edit (\e) Edit command with $EDITOR.
+ego (\G) Send command to mysql server, display result vertically.
+exit (\q) Exit mysql. Same as quit.
+go (\g) Send command to mysql server.
+nopager (\n) Disable pager, print to stdout.
+notee (\t) Don't write into outfile.
+pager (\P) Set PAGER [to_pager]. Print the query results via PAGER.
+print (\p) Print current command.
+quit (\q) Quit mysql.
+rehash (\#) Rebuild completion hash.
+source (\.) Execute a SQL script file. Takes a file name as an argument.
+status (\s) Get status information from the server.
+tee (\T) Set outfile [to_outfile]. Append everything into given outfile.
+use (\u) Use another database. Takes database name as argument.
+@end example
+
+From the above, pager only works in UNIX.
+
+@cindex status command
+The @code{status} command gives you some information about the
+connection and the server you are using. If you are running in the
+@code{--safe-updates} mode, @code{status} will also print the values for
+the @code{mysql} variables that affect your queries.
+
+@cindex @code{safe-mode} command
+A useful startup option for beginners (introduced in @strong{MySQL}
+Version 3.23.11) is @code{--safe-updates} (or @code{--i-am-a-dummy} for
+users that has at some time done a @code{DELETE FROM table_name} but
+forgot the @code{WHERE} clause). When using this option, @code{mysql}
+sends the following command to the @strong{MySQL} server when opening
+the connection:
+
+@example
+SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=#select_limit#,
+ SQL_MAX_JOIN_SIZE=#max_join_size#"
+@end example
+
+where @code{#select_limit#} and @code{#max_join_size#} are variables that
+can be set from the @code{mysql} command line. @xref{SET OPTION, @code{SET}}.
+
+The effect of the above is:
+
+@itemize @bullet
@item
-If you have any other problems with the @strong{MySQL} grant tables and
-feel you must post the problem to the mailing list, always provide a
-dump of the @strong{MySQL} grant tables. You can dump the tables with
-the @code{mysqldump mysql} command. As always, post your problem using
-the @code{mysqlbug} script. @xref{Bug reports}. In some cases you may need
-to restart @code{mysqld} with @code{--skip-grant-tables} to run
-@code{mysqldump}.
+You are not allowed to do an @code{UPDATE} or @code{DELETE} statement
+if you don't have a key constraint in the @code{WHERE} part. One can,
+however, force an @code{UPDATE/DELETE} by using @code{LIMIT}:
+@example
+UPDATE table_name SET not_key_column=# WHERE not_key_column=# LIMIT 1;
+@end example
+@item
+All big results are automatically limited to @code{#select_limit#} rows.
+@item
+@code{SELECT}'s that will probably need to examine more than
+@code{#max_join_size} row combinations will be aborted.
+@end itemize
+
+Some useful hints about the @code{mysql} client:
+
+Some data is much more readable when displayed vertically, instead of
+the usual horizontal box type output. For example longer text, which
+includes new lines, is often much easier to be read with vertical
+output.
+
+@example
+mysql> select * from mails where length(txt) < 300 limit 300,1\G
+*************************** 1. row ***************************
+ msg_nro: 3068
+ date: 2000-03-01 23:29:50
+time_zone: +0200
+mail_from: Monty
+ reply: monty@@no.spam.com
+ mail_to: "Thimble Smith" <tim@@no.spam.com>
+ sbj: UTF-8
+ txt: >>>>> "Thimble" == Thimble Smith writes:
+
+Thimble> Hi. I think this is a good idea. Is anyone familiar with UTF-8
+Thimble> or Unicode? Otherwise I'll put this on my TODO list and see what
+Thimble> happens.
+
+Yes, please do that.
+
+Regards,
+Monty
+ file: inbox-jani-1
+ hash: 190402944
+1 row in set (0.09 sec)
+@end example
+
+@itemize @bullet
+@item
+For logging, you can use the @code{tee} option. The @code{tee} can be
+started with option @code{--tee=...}, or from the command line
+interactively with command @code{tee}. All the data displayed on the
+screen will also be appended into a given file. This can be very useful
+for debugging purposes also. The @code{tee} can be disabled from the
+command line with command @code{notee}. Executing @code{tee} again
+starts logging again. Without a parameter the previous file will be
+used. Note that @code{tee} will flush the results into the file after
+each command, just before the command line appears again waiting for the
+next command.
+
+@item
+Browsing, or searching the results in the interactive mode in UNIX less,
+more, or any other similar program, is now possible with option
+@code{--pager[=...]}. Without argument, @code{mysql} client will look
+for environment variable PAGER and set @code{pager} to that.
+@code{pager} can be started from the interactive command line with
+command @code{pager} and disabled with command @code{nopager}. The
+command takes an argument optionally and the @code{pager} will be set to
+that. Command @code{pager} can be called without an argument, but this
+requires that the option @code{--pager} was used, or the @code{pager}
+will default to stdout. @code{pager} works only in UNIX, since it uses
+the popen() function, which doesn't exist in Windows. In Windows, the
+@code{tee} option can be used instead, although it may not be as handy
+as @code{pager} can be in some situations.
+
+@item
+A few tips about @code{pager}: You can use it to write to a file:
+@example
+mysql> pager cat > /tmp/log.txt
+@end example
+and the results will only go to a file. You can also pass any options
+for the programs that you want to use with the @code{pager}:
+@example
+mysql> pager less -n -i -S
+@end example
+From the above do note the option '-S'. You may find it very useful when
+browsing the results; try the option with horizontal output (end
+commands with '\g', or ';') and with vertical output (end commands with
+'\G'). Sometimes a very wide result set is hard to be read from the screen,
+with option -S to less you can browse the results within the interactive
+less from left to right, preventing lines longer than your screen from
+being continued to the next line. This can make the result set much more
+readable. You can swith the mode between on and off within the interactive
+less with '-S'. See the 'h' for more help about less.
+
+@item
+Last (unless you already understood this from the above examples ;) you
+can combine very complex ways to handle the results, for example the
+following would send the results to two files in two different
+directories, on two different hard-disks mounted on /dr1 and /dr2, yet
+let the results still be seen on the screen via less:
+@example
+mysql> pager cat | tee /dr1/tmp/res.txt | tee /dr2/tmp/res2.txt | less -n -i -S
+@end example
+
+@item
+You can also combine the two functions above; have the @code{tee}
+enabled, @code{pager} set to 'less' and you will be able to browse the
+results in unix 'less' and still have everything appended into a file
+the same time. The difference between @code{UNIX tee} used with the
+@code{pager} and the @code{mysql} client in-built @code{tee}, is that
+the in-built @code{tee} works even if you don't have the @code{UNIX tee}
+available. The in-built @code{tee} also logs everything that is printed
+on the screen, where the @code{UNIX tee} used with @code{pager} doesn't
+log quite that much. Last, but not least, the interactive @code{tee} is
+more handy to switch on and off, when you want to log something into a
+file, but want to be able to turn the feature off sometimes.
+@end itemize
+
+
+@node mysqladmin, mysqldump, mysql, Client-Side Scripts
+@subsection mysqladmin, Administrating a MySQL Server
+
+@cindex administration, server
+@cindex server administration
+@cindex @code{mysladmn}
+
+A utility for performing administrative operations. The syntax is:
+
+@example
+shell> mysqladmin [OPTIONS] command [command-option] command ...
+@end example
+
+You can get a list of the options your version of @code{mysqladmin} supports
+by executing @code{mysqladmin --help}.
+
+The current @code{mysqladmin} supports the following commands:
+
+@multitable @columnfractions .3 .7
+@item create databasename @tab Create a new database.
+@item drop databasename @tab Delete a database and all its tables.
+@item extended-status @tab Gives an extended status message from the server.
+@item flush-hosts @tab Flush all cached hosts.
+@item flush-logs @tab Flush all logs.
+@item flush-tables @tab Flush all tables.
+@item flush-privileges @tab Reload grant tables (same as reload).
+@item kill id,id,... @tab Kill mysql threads.
+@item password @tab New-password. Change old password to new-password.
+@item ping @tab Check if @code{mysqld} is alive.
+@item processlist @tab Show list of active threads in server.
+@item reload @tab Reload grant tables.
+@item refresh @tab Flush all tables and close and open logfiles.
+@item shutdown @tab Take server down.
+@item slave-start @tab Start slave replication thread.
+@item slave-stop @tab Stop slave replication thread.
+@item status @tab Gives a short status message from the server.
+@item variables @tab Prints variables available.
+@item version @tab Get version info from server.
+@end multitable
+
+All commands can be shortened to their unique prefix. For example:
+
+@example
+shell> mysqladmin proc stat
++----+-------+-----------+----+-------------+------+-------+------+
+| Id | User | Host | db | Command | Time | State | Info |
++----+-------+-----------+----+-------------+------+-------+------+
+| 6 | monty | localhost | | Processlist | 0 | | |
++----+-------+-----------+----+-------------+------+-------+------+
+Uptime: 10077 Threads: 1 Questions: 9 Slow queries: 0 Opens: 6 Flush tables: 1 Open tables: 2 Memory in use: 1092K Max memory used: 1116K
+@end example
+
+@cindex status command, results
+The @code{mysqladmin status} command result has the following columns:
+
+@cindex uptime
+@multitable @columnfractions .3 .7
+@item Uptime @tab Number of seconds the @strong{MySQL} server has been up.
+@cindex threads
+@item Threads @tab Number of active threads (clients).
+@cindex questions
+@item Questions @tab Number of questions from clients since @code{mysqld} was started.
+@cindex slow queries
+@item Slow queries @tab Queries that have taken more than @code{long_query_time} seconds. @xref{Slow query log}.
+@cindex opens
+@item Opens @tab How many tables @code{mysqld} has opened.
+@cindex flush tables
+@cindex tables, flush
+@item Flush tables @tab Number of @code{flush ...}, @code{refresh}, and @code{reload} commands.
+@cindex open tables
+@item Open tables @tab Number of tables that are open now.
+@cindex memory use
+@item Memory in use @tab Memory allocated directly by the @code{mysqld} code (only available when @strong{MySQL} is compiled with --with-debug=full).
+@cindex max memory used
+@item Max memory used @tab Maximum memory allocated directly by the @code{mysqld} code (only available when @strong{MySQL} is compiled with --with-debug=full).
+@end multitable
+
+If you do @code{myslqadmin shutdown} on a socket (in other words, on a
+the computer where @code{mysqld} is running), @code{mysqladmin} will
+wait until the @strong{MySQL} @code{pid-file} is removed to ensure that
+the @code{mysqld} server has stopped properly.
+
+
+@node mysqldump, mysqlhotcopy, mysqladmin, Client-Side Scripts
+@subsection mysqldump, Dumping Table Structure and Data
+
+@cindex dumping, databases
+@cindex databases, dumping
+@cindex tables, dumping
+@cindex backing up, databases
+
+@cindex @code{mysqldump}
+Utility to dump a database or a collection of database for backup or for
+transferring the data to another SQL server (not necessarily a @strong{MySQL}
+server). The dump will contain SQL statements to create the table
+and/or populate the table.
+
+If you are doing a backup on the server, you should consider using
+the @code{mysqlhotcopy} instead. @xref{mysqlhotcopy, , @code{mysqlhotcopy}}.
+
+@example
+shell> mysqldump [OPTIONS] database [tables]
+OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
+OR mysqldump [OPTIONS] --all-databases [OPTIONS]
+@end example
+
+If you don't give any tables or use the @code{--databases} or
+@code{--all-databases}, the whole database(s) will be dumped.
+
+You can get a list of the options your version of @code{mysqldump} supports
+by executing @code{mysqldump --help}.
+
+Note that if you run @code{mysqldump} without @code{--quick} or
+@code{--opt}, @code{mysqldump} will load the whole result set into
+memory before dumping the result. This will probably be a problem if
+you are dumping a big database.
+
+Note that if you are using a new copy of the @code{mysqldump} program
+and you are going to do a dump that will be read into a very old @strong{MySQL}
+server, you should not use the @code{--opt} or @code{-e} options.
+
+@code{mysqldump} supports the following options:
+
+@table @code
+@item --add-locks
+Add @code{LOCK TABLES} before and @code{UNLOCK TABLE} after each table dump.
+(To get faster inserts into @strong{MySQL}.)
+@item --add-drop-table
+Add a @code{drop table} before each create statement.
+@item -A, --all-databases
+Dump all the databases. This will be same as @code{--databases} with all
+databases selected.
+@item -a, --all
+Include all @strong{MySQL}-specific create options.
+@item --allow-keywords
+Allow creation of column names that are keywords. This works by
+prefixing each column name with the table name.
+@item -c, --complete-insert
+Use complete insert statements (with column names).
+@item -C, --compress
+Compress all information between the client and the server if both support
+compression.
+@item -B, --databases
+To dump several databases. Note the difference in usage. In this case
+no tables are given. All name arguments are regarded as database names.
+@code{USE db_name;} will be included in the output before each new database.
+@item --delayed
+Insert rows with the @code{INSERT DELAYED} command.
+@item -e, --extended-insert
+Use the new multiline @code{INSERT} syntax. (Gives more compact and
+faster inserts statements.)
+@item -#, --debug[=option_string]
+Trace usage of the program (for debugging).
+@item --help
+Display a help message and exit.
+@item --fields-terminated-by=...
+@itemx --fields-enclosed-by=...
+@itemx --fields-optionally-enclosed-by=...
+@itemx --fields-escaped-by=...
+@itemx --lines-terminated-by=...
+These options are used with the @code{-T} option and have the same
+meaning as the corresponding clauses for @code{LOAD DATA INFILE}.
+@xref{LOAD DATA, , @code{LOAD DATA}}.
+@item -F, --flush-logs
+Flush log file in the @strong{MySQL} server before starting the dump.
+@item -f, --force,
+Continue even if we get a SQL error during a table dump.
+@item -h, --host=..
+Dump data from the @strong{MySQL} server on the named host. The default host
+is @code{localhost}.
+@item -l, --lock-tables.
+Lock all tables before starting the dump. The tables are locked with
+@code{READ LOCAL} to allow concurrent inserts in the case of @code{MyISAM}
+tables.
+@item -n, --no-create-db
+'CREATE DATABASE /*!32312 IF NOT EXISTS*/ db_name;' will not be put in the
+output. The above line will be added otherwise, if --databases or
+--all-databases option was given.
+@item -t, --no-create-info
+Don't write table creation information (The @code{CREATE TABLE} statement.)
+@item -d, --no-data
+Don't write any row information for the table. This is very useful if you
+just want to get a dump of the structure for a table!
+@item --opt
+Same as @code{--quick --add-drop-table --add-locks --extended-insert
+--lock-tables}. Should give you the fastest possible dump for reading
+into a @strong{MySQL} server.
+@item -pyour_pass, --password[=your_pass]
+The password to use when connecting to the server. If you specify
+no @samp{=your_pass} part,
+@code{mysqldump} you will be prompted for a password.
+@item -P port_num, --port=port_num
+The TCP/IP port number to use for connecting to a host. (This is used for
+connections to hosts other than @code{localhost}, for which Unix sockets are
+used.)
+@item -q, --quick
+Don't buffer query, dump directly to stdout. Uses @code{mysql_use_result()}
+to do this.
+@item -r, --result-file=...
+Direct output to a given file. This option should be used in MSDOS,
+because it prevents new line '\n' from being converted to '\n\r' (new
+line + carriage return).
+@item -S /path/to/socket, --socket=/path/to/socket
+The socket file to use when connecting to @code{localhost} (which is the
+default host).
+@item --tables
+Overrides option --databases (-B).
+@item -T, --tab=path-to-some-directory
+Creates a @code{table_name.sql} file, that contains the SQL CREATE commands,
+and a @code{table_name.txt} file, that contains the data, for each give table.
+@strong{NOTE}: This only works if @code{mysqldump} is run on the same
+machine as the @code{mysqld} daemon. The format of the @code{.txt} file
+is made according to the @code{--fields-xxx} and @code{--lines--xxx} options.
+@item -u user_name, --user=user_name
+The @strong{MySQL} user name to use when connecting to the server. The
+default value is your Unix login name.
+@item -O var=option, --set-variable var=option
+Set the value of a variable. The possible variables are listed below.
+@item -v, --verbose
+Verbose mode. Print out more information on what the program does.
+@item -V, --version
+Print version information and exit.
+@item -w, --where='where-condition'
+Dump only selected records. Note that QUOTES are mandatory:
+
+@example
+"--where=user='jimf'" "-wuserid>1" "-wuserid<1"
+@end example
+@item -O net_buffer_length=#, where # < 16M
+When creating multi-row-insert statements (as with option
+@code{--extended-insert} or @code{--opt}), @code{mysqldump} will create
+rows up to @code{net_buffer_length} length. If you increase this
+variable, you should also ensure that the @code{max_allowed_packet}
+variable in the @strong{MySQL} server is bigger than the
+@code{net_buffer_length}.
+@end table
+
+The most normal use of @code{mysqldump} is probably for making a backup of
+whole databases. @xref{Backup}.
+
+@example
+mysqldump --opt database > backup-file.sql
+@end example
+
+You can read this back into @strong{MySQL} with:
+
+@example
+mysql database < backup-file.sql
+@end example
+
+or
+
+@example
+mysql -e "source /patch-to-backup/backup-file.sql" database
+@end example
+
+However, it's also very useful to populate another @strong{MySQL} server with
+information from a database:
+
+@example
+mysqldump --opt database | mysql ---host=remote-host -C database
+@end example
+
+It is possible to dump several databases with one command:
+
+@example
+mysqldump --databases database1 [database2 database3...] > my_databases.sql
+@end example
+
+If all the databases are wanted, one can use:
+
+@example
+mysqldump --all-databases > all_databases.sql
+@end example
+
+
+@node mysqlhotcopy, mysqlimport, mysqldump, Client-Side Scripts
+@subsection mysqlhotcopy, Copying MySQL Databases and Tables
+
+@cindex dumping, databases
+@cindex databases, dumping
+@cindex tables, dumping
+@cindex backing up, databases
+
+@code{mysqlhotcopy} is a perl script that uses @code{LOCK TABLES},
+@code{FLUSH TABLES} and @code{cp} or @code{scp} to quickly make a backup
+of a database. It's the fastest way to make a backup of the database,
+of single tables but it can only be run on the same machine where the
+database directories are.
+
+@example
+mysqlhotcopy db_name [/path/to/new_directory]
+
+mysqlhotcopy db_name_1 ... db_name_n /path/to/new_directory
+
+mysqlhotcopy db_name./regex/
+@end example
+
+@code{mysqlhotcopy} supports the following options:
+
+@table @code
+@item -?, --help
+Display a help screen and exit
+@item -u, --user=#
+User for database login
+@item -p, --password=#
+Password to use when connecting to server
+@item -P, --port=#
+Port to use when connecting to local server
+@item -S, --socket=#
+Socket to use when connecting to local server
+@item --allowold
+Don't abort if target already exists (rename it _old)
+@item --keepold
+Don't delete previous (now renamed) target when done
+@item --noindices
+Don't include full index files in copy to make the backup smaller and faster
+The indexes can later be reconstructed with @code{myisamchk -rq.}.
+@item --method=#
+Method for copy (@code{cp} or @code{scp}).
+@item -q, --quiet
+Be silent except for errors
+@item --debug
+Enable debug
+@item -n, --dryrun
+Report actions without doing them
+@item --regexp=#
+Copy all databases with names matching regexp
+@item --suffix=#
+Suffix for names of copied databases
+@item --checkpoint=#
+Insert checkpoint entry into specified db.table
+@item --flushlog
+Flush logs once all tables are locked.
+@item --tmpdir=#
+Temporary directory (instead of /tmp).
+@end table
+
+You can use @code{perldoc mysqlhotcopy} to get a more complete
+documentation for @code{mysqlhotcopy}.
+
+@code{mysqlhotcopy} reads the groups @code{[client]} and @code{[mysqlhotcopy]}
+from the option files.
+
+To be able to execute @code{mysqlhotcopy} you need write access to the
+backup directory, @code{SELECT} privilege to the tables you are about to
+copy and the @strong{MySQL} @code{Reload} privilege (to be able to
+execute @code{FLUSH TABLES}).
+
+
+@node mysqlimport, mysqlshow, mysqlhotcopy, Client-Side Scripts
+@subsection mysqlimport, Importing Data from Text Files
+
+@cindex importing, data
+@cindex data, importing
+@cindex files, text
+@cindex text files, importing
+@cindex @code{mysqlimport}
+
+@code{mysqlimport} provides a command-line interface to the @code{LOAD DATA
+INFILE} SQL statement. Most options to @code{mysqlimport} correspond
+directly to the same options to @code{LOAD DATA INFILE}.
+@xref{LOAD DATA, , @code{LOAD DATA}}.
+
+@code{mysqlimport} is invoked like this:
+
+@example
+shell> mysqlimport [options] database textfile1 [textfile2....]
+@end example
+
+For each text file named on the command line,
+@code{mysqlimport} strips any extension from the filename and uses the result
+to determine which table to import the file's contents into. For example,
+files named @file{patient.txt}, @file{patient.text}, and @file{patient} would
+all be imported into a table named @code{patient}.
+
+@code{mysqlimport} supports the following options:
+
+@table @code
+@item -c, --columns=...
+This option takes a comma-separated list of field names as an argument.
+The field list is used to create a proper @code{LOAD DATA INFILE} command,
+which is then passed to @strong{MySQL}. @xref{LOAD DATA, , @code{LOAD DATA}}.
+
+@item -C, --compress
+Compress all information between the client and the server if both support
+compression.
+
+@item -#, --debug[=option_string]
+Trace usage of the program (for debugging).
+
+@item -d, --delete
+Empty the table before importing the text file.
+
+@item --fields-terminated-by=...
+@itemx --fields-enclosed-by=...
+@itemx --fields-optionally-enclosed-by=...
+@itemx --fields-escaped-by=...
+@itemx --lines-terminated-by=...
+These options have the same meaning as the corresponding clauses for
+@code{LOAD DATA INFILE}. @xref{LOAD DATA, , @code{LOAD DATA}}.
+
+@item -f, --force
+Ignore errors. For example, if a table for a text file doesn't exist,
+continue processing any remaining files. Without @code{--force},
+@code{mysqlimport} exits if a table doesn't exist.
+
+@item --help
+Display a help message and exit.
+
+@item -h host_name, --host=host_name
+Import data to the @strong{MySQL} server on the named host. The default host
+is @code{localhost}.
+
+@item -i, --ignore
+See the description for the @code{--replace} option.
+
+@item -l, --lock-tables
+Lock @strong{ALL} tables for writing before processing any text files. This
+ensures that all tables are synchronized on the server.
+
+@item -L, --local
+Read input files from the client. By default, text files are assumed to be on
+the server if you connect to @code{localhost} (which is the default host).
+
+@item -pyour_pass, --password[=your_pass]
+The password to use when connecting to the server. If you specify
+no @samp{=your_pass} part,
+@code{mysqlimport} you will be prompted for a password.
+
+@item -P port_num, --port=port_num
+The TCP/IP port number to use for connecting to a host. (This is used for
+connections to hosts other than @code{localhost}, for which Unix sockets are
+used.)
+
+@item -r, --replace
+The @code{--replace} and @code{--ignore} options control handling of input
+records that duplicate existing records on unique key values. If you specify
+@code{--replace}, new rows replace existing rows that have the same unique key
+value. If you specify @code{--ignore}, input rows that duplicate an existing
+row on a unique key value are skipped. If you don't specify either option, an
+error occurs when a duplicate key value is found, and the rest of the text
+file is ignored.
+
+@item -s, --silent
+Silent mode. Write output only when errors occur.
+
+@item -S /path/to/socket, --socket=/path/to/socket
+The socket file to use when connecting to @code{localhost} (which is the
+default host).
+
+@item -u user_name, --user=user_name
+The @strong{MySQL} user name to use when connecting to the server. The
+default value is your Unix login name.
+
+@item -v, --verbose
+Verbose mode. Print out more information what the program does.
+
+@item -V, --version
+Print version information and exit.
+@end table
+
+Here is a sample run using @code{mysqlimport}:
+
+@example
+$ mysql --version
+mysql Ver 9.33 Distrib 3.22.25, for pc-linux-gnu (i686)
+$ uname -a
+Linux xxx.com 2.2.5-15 #1 Mon Apr 19 22:21:09 EDT 1999 i586 unknown
+$ mysql -e 'CREATE TABLE imptest(id INT, n VARCHAR(30))' test
+$ ed
+a
+100 Max Sydow
+101 Count Dracula
+.
+w imptest.txt
+32
+q
+$ od -c imptest.txt
+0000000 1 0 0 \t M a x S y d o w \n 1 0
+0000020 1 \t C o u n t D r a c u l a \n
+0000040
+$ mysqlimport --local test imptest.txt
+test.imptest: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0
+$ mysql -e 'SELECT * FROM imptest' test
++------+---------------+
+| id | n |
++------+---------------+
+| 100 | Max Sydow |
+| 101 | Count Dracula |
++------+---------------+
+@end example
+
+
+@node mysqlshow, , mysqlimport, Client-Side Scripts
+@subsection Showing Databases, Tables, and Columns
+
+@cindex databases, displaying
+@cindex displaying, database information
+@cindex tables, displaying
+@cindex columns, displaying
+@cindex showing, database information
+
+@code{mysqlshow} can be used to quickly look at which databases exist,
+their tables, and the table's columns.
+
+With the @code{mysql} program you can get the same information with the
+@code{SHOW} commands. @xref{SHOW}.
+
+@code{mysqlshow} is invoked like this:
+
+@example
+shell> mysqlshow [OPTIONS] [database [table [column]]]
+@end example
+
+@itemize @bullet
+@item
+If no database is given, all matching databases are shown.
+@item
+If no table is given, all matching tables in the database are shown.
+@item
+If no column is given, all matching columns and column types in the table
+are shown.
+@end itemize
+
+Note that in newer @strong{MySQL} versions, you only see those
+database/tables/columns for which you have some privileges.
+
+If the last argument contains a shell or SQL wild-card (@code{*}, @code{?},
+@code{%} or @code{_}) then only what's matched by the wild card is shown.
+This may cause some confusion when you try to display the columns for a
+table with a @code{_} as in this case @code{mysqlshow} only shows you
+the table names that match the pattern. This is easily fixed by
+adding an extra @code{%} last on the command line (as a separate
+argument).
+
+
+@node perror, Batch Commands, Client-Side Scripts, MySQL Database Administration
+@section perror, Explaining Error Codes
+
+@cindex error messages, displaying
+@cindex perror
+
+@code{perror} can be used to print error message(s). @code{perror} can
+be invoked like this:
+
+@example
+shell> perror [OPTIONS] [ERRORCODE [ERRORCODE...]]
+
+For example:
+
+shell> perror 64 79
+Error code 64: Machine is not on the network
+Error code 79: Can not access a needed shared library
+@end example
+
+@code{perror} can be used to display a description for a system error
+code, or an MyISAM/ISAM table handler error code. The error messages
+are mostly system dependent.
+
+
+@node Batch Commands, Log Files, perror, MySQL Database Administration
+@section How to Run SQL Commands from a Text File
+
+@c FIX add the 'source' command
+
+The @code{mysql} client typically is used interactively, like this:
+
+@example
+shell> mysql database
+@end example
+
+However, it's also possible to put your SQL commands in a file and tell
+@code{mysql} to read its input from that file. To do so, create a text
+file @file{text_file} that contains the commands you wish to execute.
+Then invoke @code{mysql} as shown below:
+
+@example
+shell> mysql database < text_file
+@end example
+
+You can also start your text file with a @code{USE db_name} statement. In
+this case, it is unnecessary to specify the database name on the command
+line:
+
+@example
+shell> mysql < text_file
+@end example
+
+@xref{Client-Side Scripts}.
+
+
+@node Log Files, Log file maintenance, Batch Commands, MySQL Database Administration
+@section The MySQL Log Files
+
+@cindex Log files
+
+@strong{MySQL} has several different log files that can help you find
+out what's going on inside @code{mysqld}:
+
+@multitable @columnfractions .3 .7
+@item The error log @tab Problems encountering starting, running or stopping @code{mysqld}.
+@item The isam log @tab Logs all changes to the ISAM tables. Used only for debugging the isam code.
+@item The query log @tab Established connections and executed queries.
+@item The update log @tab Deprecated: Stores all statements that changes data
+@item The binary log @tab Stores all statements that changes something. Used also for replication
+@item The slow log @tab Stores all queries that took more than @code{long_query_time} to execute or didn't use indexes.
+@end multitable
+
+All logs can be found in the @code{mysqld} data directory. You can
+force @code{mysqld} to reopen the log files (or in some cases
+switch to a new log) by executing @code{FLUSH LOGS}. @xref{FLUSH}.
+
+@menu
+* Error log::
+* Query log::
+* Update log::
+* Binary log::
+* Slow query log::
+@end menu
+
+
+@node Error log, Query log, Log Files, Log Files
+@subsection The Error Log
+
+@code{mysqld} writes all errors to the stderr, which the
+@code{safe_mysqld} script redirects to a file called
+@code{'hostname'.err}. (On Windows, @code{mysqld} writes this directly
+to @file{\mysql\data\mysql.err}).
+
+This contains information indicating when @code{mysqld} was started and
+stopped and also any critical errors found when running. If @code{mysqld}
+dies unexpectedly and @code{safe_mysqld} needs to restart @code{mysqld},
+@code{safe_mysqld} will write a @code{restarted mysqld} row in this
+file. This log also holds a warning if @code{mysqld} notices a table
+that needs to be automatically checked or repaired.
+
+On some operating systems, the error log will contain a stack trace
+for where @code{mysqld} died. This can be used to find out where
+@code{mysqld} died. @xref{Using stack trace}.
+
+
+@node Query log, Update log, Error log, Log Files
+@subsection The General Query Log
+
+@cindex query log
+@cindex files, query log
+
+If you want to know what happens within @code{mysqld}, you should start
+it with @code{--log[=file]}. This will log all connections and queries
+to the log file (by default named @file{'hostname'.log}). This log can
+be very useful when you suspect an error in a client and want to know
+exactly what @code{mysqld} thought the client sent to it.
+
+By default, the @code{mysql.server} script starts the @strong{MySQL}
+server with the @code{-l} option. If you need better performance when
+you start using @strong{MySQL} in a production environment, you can
+remove the @code{-l} option from @code{mysql.server} or change it to
+@code{--log-binary}.
+
+The entries in this log are written as @code{mysqld} receives the questions.
+This may be different than the order in which the statements are executed.
+This is in contrast to the update log and the binary log which are written
+after the query is executed, but before any locks are released.
+
+
+@node Update log, Binary log, Query log, Log Files
+@subsection The Update Log
+
+@cindex update log
+@cindex files, update log
+
+@strong{NOTE}: The update log is replaced by the binary
+log. @xref{Binary log}. With this you can do anything that you can do
+with the update log.
+
+When started with the @code{--log-update[=file_name]} option,
+@code{mysqld} writes a log file containing all SQL commands that update
+data. If no filename is given, it defaults to the name of the host
+machine. If a filename is given, but it doesn't contain a path, the file
+is written in the data directory. If @file{file_name} doesn't have an
+extension, @code{mysqld} will create log file names like so:
+@file{file_name.###}, where @code{###} is a number that is incremented each
+time you execute @code{mysqladmin refresh}, execute @code{mysqladmin
+flush-logs}, execute the @code{FLUSH LOGS} statement, or restart the server.
+
+@strong{NOTE:} For the above scheme to work, you should NOT create
+your own files with the same filename as the update log + some extensions
+that may be regarded as a number, in the directory used by the update log!
+
+If you use the @code{--log} or @code{-l} options, @code{mysqld} writes a
+general log with a filename of @file{hostname.log}, and restarts and
+refreshes do not cause a new log file to be generated (although it is closed
+and reopened). In this case you can copy it (on Unix) by doing:
+
+@example
+mv hostname.log hostname-old.log
+mysqladmin flush-logs
+cp hostname-old.log to-backup-directory
+rm hostname-old.log
+@end example
+
+Update logging is smart because it logs only statements that really update
+data. So an @code{UPDATE} or a @code{DELETE} with a @code{WHERE} that finds no
+rows is not written to the log. It even skips @code{UPDATE} statements that
+set a column to the value it already has.
+
+The update logging is done immediately after a query completes but before
+any locks are released or any commit is done. This ensures that the log
+will be logged in the execution order.
+
+If you want to update a database from update log files, you could do the
+following (assuming your update logs have names of the form
+@file{file_name.###}):
+
+@example
+shell> ls -1 -t -r file_name.[0-9]* | xargs cat | mysql
+@end example
+
+@code{ls} is used to get all the log files in the right order.
+
+This can be useful if you have to revert to backup files after a crash
+and you want to redo the updates that occurred between the time of the backup
+and the crash.
+
+
+@node Binary log, Slow query log, Update log, Log Files
+@subsection The Binary Update Log
+
+@cindex binary log
+@cindex files, binary log
+
+In the future the binary log will replace the update log, so we
+recommend you to switch to this log format as soon as possible!
+
+The binary log contains all information that is available in the update
+log in a more efficient format. It also contains information about how long
+every query that updated the database took.
+
+The binary log is also used when you are replicating a slave from a master.
+@xref{Replication}.
+
+When started with the @code{--log-bin[=file_name]} option, @code{mysqld}
+writes a log file containing all SQL commands that update data. If no
+file name is given, it defaults to the name of the host machine followed
+by @code{-bin}. If file name is given, but it doesn't contain a path, the
+file is written in the data directory.
+
+You can use the following options to @code{mysqld} to affect what is logged
+to the binary log:
+
+@multitable @columnfractions .4 .6
+@item @code{binlog-do-db=database_name} @tab
+Tells the master it should log updates for the specified database, and
+exclude all others not explicitly mentioned.
+(Example: @code{binlog-do-db=some_database})
+
+@item @code{binlog-ignore-db=database_name} @tab
+Tells the master that updates to the given database should not be logged
+to the binary log (Example: @code{binlog-ignore-db=some_database})
+@end multitable
+
+To the binary log filename @code{mysqld} will append an extension that is a
+number that is incremented each time you execute @code{mysqladmin
+refresh}, execute @code{mysqladmin flush-logs}, execute the @code{FLUSH LOGS}
+statement or restart the server.
+
+To be able to know which different binary log files have been used,
+@code{mysqld} will also create a binary log index file that
+contains the name of all used binary log files. By default this has the
+same name as the binary log file, with the extension @code{'.index'}.
+You can change the name of the binary log index file with the
+@code{--log-bin-index=[filename]} option.
+
+If you are using replication, you should not delete old binary log
+files until you are sure that no slave will ever need to use them.
+One way to do this is to do @code{mysqladmin flush-logs} once a day and then
+remove any logs that are more than 3 days old.
+
+You can examine the binary log file with the @code{mysqlbinlog} command.
+For example, you can update a @strong{MySQL} server from the binary log
+as follows:
+
+@example
+mysqlbinlog log-file | mysql -h server_name
+@end example
+
+You can also use the @code{mysqlbinlog} program to read the binary log
+directly from a remote @strong{MySQL} server!
+
+@code{mysqlbinlog --help} will give you more information of how to use
+this program!
+
+If you are using @code{BEGIN [WORK]} or @code{SET AUTOCOMMIT=0}, you must
+use the @strong{MySQL} binary log for backups instead of the old update log.
+
+The binary logging is done immediately after a query completes but before
+any locks are released or any commit is done. This ensures that the log
+will be logged in the execution order.
+
+All updates (@code{UPDATE}, @code{DELETE} or @code{INSERT}) that change
+a transactional table (like BDB tables) are cached until a @code{COMMIT}.
+Any updates to a non-transactional table are stored in the binary log at
+once. Every thread will, on start, allocate a buffer of
+@code{binlog_cache_size} to buffer queries. If a query is bigger than
+this, the thread will open a temporary file to handle the bigger cache.
+The temporary file will be deleted when the thread ends.
+
+The @code{max_binlog_cache_size} can be used to restrict the total size used
+to cache a multi-transaction query.
+
+If you are using the update or binary log, concurrent inserts will
+not work together with @code{CREATE ... INSERT} and @code{INSERT ... SELECT}.
+This is to ensure that you can recreate an exact copy of your tables by
+applying the log on a backup.
+
+
+@node Slow query log, , Binary log, Log Files
+@subsection The Slow Query Log
+
+@cindex slow query log
+@cindex files, slow query log
+
+When started with the @code{--log-slow-queries[=file_name]} option,
+@code{mysqld} writes a log file containing all SQL commands that took
+more than @code{long_query_time} to execute. The time to get the initial
+table locks are not counted as execution time.
+
+The slow query log is logged after the query is executed and after all
+locks has been released. This may be different than the order in which
+the statements are executed.
+
+If no file name is given, it defaults to the name of the host machine
+suffixed with @code{-slow.log}. If a filename is given, but doesn't
+contain a path, the file is written in the data directory.
+
+The slow query log can be used to find queries that take a long time to
+execute and are thus candidates for optimization. With a large log, that
+can become a difficult task. You can pipe the slow query log through the
+@code{mysqldumpslow} command to get a summary of the queries which
+appear in the log.
+
+You are using @code{--log-long-format} then also queries that are not
+using indexes are printed. @xref{Command-line options}.
+
+
+@node Log file maintenance, Replication, Log Files, MySQL Database Administration
+@section Log File Maintenance
+
+@cindex files, log
+@cindex maintaining, log files
+@cindex log files, maintaining
+
+@strong{MySQL} has a lot of log files which make it easy to see what is
+going. @xref{Log Files}. One must however from time to time clean up
+after @code{MysQL} to ensure that the logs don't take up too much disk
+space.
+
+When using @strong{MySQL} with log files, you will, from time to time,
+want to remove/backup old log files and tell @strong{MySQL} to start
+logging on new files. @xref{Backup}.
+
+On a Linux (@code{Redhat}) installation, you can use the
+@code{mysql-log-rotate} script for this. If you installed @strong{MySQL}
+from an RPM distribution, the script should have been installed
+automatically. Note that you should be careful with this if you are using
+the log for replication!
+
+On other systems you must install a short script yourself that you
+start from @code{cron} to handle log files.
+
+You can force @strong{MySQL} to start using new log files by using
+@code{mysqladmin flush-logs} or by using the SQL command @code{FLUSH LOGS}.
+If you are using @strong{MySQL} Version 3.21 you must use @code{mysqladmin refresh}.
+
+The above command does the following:
+
+@itemize @bullet
+@item
+If standard logging (@code{--log}) or slow query logging
+(@code{--log-slow-queries}) is used, closes and reopens the log file.
+(@file{mysql.log} and @file{`hostname`-slow.log} as default).
+@item
+If update logging (@code{--log-update}) is used, closes the update log and
+opens a new log file with a higher sequence number.
+@end itemize
+
+If you are using only an update log, you only have to flush the logs and then
+move away the old update log files to a backup.
+If you are using the normal logging, you can do something like:
+
+@example
+shell> cd mysql-data-directory
+shell> mv mysql.log mysql.old
+shell> mysqladmin flush-logs
+@end example
+
+and then take a backup and remove @file{mysql.old}.
+
+
+@node Replication, Replication HOWTO, Log file maintenance, MySQL Database Administration
+@section Replication in MySQL
+
+@cindex replication
+@cindex increasing, speed
+@cindex speed, increasing
+@cindex databases, replicating
+
+@menu
+* Replication Intro::
+* Replication Implementation::
+@end menu
+
+This chapter describes the various replication features in @strong{MySQL}.
+It serves as a reference to the options available with replication.
+You will be introduced to replication and learn how to implement it.
+Towards the end, there are some frequently asked questions and descriptions
+of problems and how to solve them.
+
+
+@node Replication Intro, Replication Implementation, Replication, Replication
+@subsection Introduction
+
+One way replication can be used is to increase both robustness and
+speed. For robustness you can have two systems and can switch to the backup if
+you have problems with the master. The extra speed is achieved by
+sending a part of the non-updating queries to the replica server. Of
+course this only works if non-updating queries dominate, but that is the
+normal case.
+
+Starting in Version 3.23.15, @strong{MySQL} supports one-way replication
+internally. One server acts as the master, while the other acts as the
+slave. Note that one server could play the roles of master in one pair
+and slave in the other. The master server keeps a binary log of updates
+(@xref{Binary log}.) and an index file to binary logs to keep track of
+log rotation. The slave, upon connecting, informs the master where it
+left off since the last successfully propagated update, catches up on
+the updates, and then blocks and waits for the master to notify it of
+the new updates.
+
+Note that if you are replicating a database, all updates to this
+database should be done through the master!
+
+On older servers one can use the update log to do simple replication.
+@xref{Log Replication}.
+
+Another benefit of using replication is that one can get live backups of
+the system by doing a backup on a slave instead of doing it on the
+master. @xref{Backup}.
+
+
+@node Replication Implementation, , Replication Intro, Replication
+@subsection Replication Implementation Overview
+
+@cindex master-slave setup
+
+@strong{MySQL} replication is based on the server keeping track of all
+changes to your database (updates, deletes, etc) in the binary
+log. (@xref{Binary log}.) and the slave server(s) reading the saved
+queries from the master server's binary log so that the slave can
+execute the same queries on its copy of the data.
+
+It is @strong{very important} to realize that the binary log is simply a
+record starting from a fixed point in time (the moment you enable binary
+logging). Any slaves which you set up will need copies of all the data
+from your master as it existed the moment that you enabled binary
+logging on the master. If you start your slaves with data that doesn't
+agree with what was on the master @strong{when the binary log was
+started}, your slaves may fail.
+
+A future version (4.0) of @strong{MySQL} will remove the need to keep a
+(possibly large) snapshot of data for new slaves that you might wish to
+set up through the live backup functionality with no locking required.
+However, at this time, it is necessary to block all writes either with a
+global read lock or by shutting down the master while taking a snapshot.
+
+Once a slave is properly configured and running, it will simply connect
+to the master and wait for updates to process. If the master goes away
+or the slave loses connectivity with your master, it will keep trying to
+connect every @code{master-connect-retry} seconds until it is able to
+reconnect and resume listening for updates.
+
+Each slave keeps track of where it left off. The master server has no
+knowledge of how many slaves there are or which ones are up-to-date at
+any given time.
+
+The next section explains the master/slave setup process in more detail.
+
+
+@node Replication HOWTO, , Replication, MySQL Database Administration
+@section How To Set Up Replication
+
+Below is a quick description of how to set up complete replication on
+your current @strong{MySQL} server. It assumes you want to replicate all
+your databases and have not configured replication before. You will need
+to shutdown your master server briefly to complete the steps outlined
+below.
+
+@enumerate
+@item
+Make sure you have a recent version of @strong{MySQL} installed on the master
+and slave(s).
+
+Use Version 3.23.29 or higher. Previous releases used a different binary
+log format and had bugs which have been fixed in newer releases. Please,
+do not report bugs until you have verified that the problem is present
+in the latest release.
+
+@item
+Set up special a replication user on the master with the @code{FILE}
+privilege and permission to connect from all the slaves. If the user is
+only doing replication (which is recommended), you don't need to grant any
+additional privileges.
+
+For example, to create a user named @code{repl} which can access your
+master from any host, you might use this command:
+
+@example
+GRANT FILE ON *.* TO repl@@"%" IDENTIFIED BY '<password>';
+@end example
+
+@item
+Shut down @strong{MySQL} on the master.
+
+@example
+mysqladmin -u root -p<password> shutdown
+@end example
+
+@item
+Snapshot all the data on your master server.
+
+The easiest way to do this (on Unix) is to simply use @strong{tar} to
+produce an archive of your entire data directory. The exact data
+directory location depends on your installation.
+
+@example
+tar -cvf /tmp/mysql-snapshot.tar /path/to/data-dir
+@end example
+
+Windows users can use WinZip or similar software to create an archive of
+the data directory.
+
+@item
+In @code{my.cnf} on the master add @code{log-bin} and
+@code{server-id=unique number} to the @code{[mysqld]} section and
+restart it. It is very important that the id of the slave is different from
+the id of the master. Think of @code{server-id} as something similar
+to the IP address - it uniquely identifies the server instance in the
+community of replication partners.
+
+@example
+[mysqld]
+log-bin
+server-id=1
+@end example
+
+@item
+Restart @strong{MySQL} on the master.
+
+@item
+Add the following to @code{my.cnf} on the slave(s):
+
+@example
+master-host=<hostname of the master>
+master-user=<replication user name>
+master-password=<replication user password>
+master-port=<TCP/IP port for master>
+server-id=<some unique number between 2 and 2^32-1>
+@end example
+
+replacing the values in <> with what is relevant to your system.
+
+@code{server-id} must be different for each server participating in
+replication. If you don't specify a server-id, it will be set to 1 if
+you have not defined @code{master-host}, else it will be set to 2. Note
+that in the case of @code{server-id} omission the master will refuse
+connections from all slaves, and the slave will refuse to connect to a
+master. Thus, omitting @code{server-id} is only good for backup with a
+binary log.
+
+
+@item
+Copy the snapshot data into your data directory on your slave(s). Make
+sure that the privileges on the files and directories are correct. The
+user which @strong{MySQL} runs as needs to be able to read and write to
+them, just as on the master.
+
+@item Restart the slave(s).
+
+@end enumerate
+
+After you have done the above, the slave(s) should connect to the master
+and catch up on any updates which happened since the snapshot was taken.
+
+If you have forgotten to set @code{server-id} for the slave you will get
+the following error in the error log file:
+
+@example
+Warning: one should set server_id to a non-0 value if master_host is set.
+The server will not act as a slave.
+@end example
+
+If you have forgot to do this for the master, the slaves will not be
+able to connect to the master.
+
+If a slave is not able to replicate for any reason, you will find error
+messages in the error log on the slave.
+
+Once a slave is replicating, you will find a file called
+@code{master.info} in the same directory as your error log. The
+@code{master.info} file is used by the slave to keep track of how much
+of the master's binary log is has processed. @strong{Do not} remove or
+edit the file, unless you really know what you are doing. Even in that case,
+it is preferred that you use @code{CHANGE MASTER TO} command.
+
+
+@menu
+* Replication Features::
+* Replication Options::
+* Replication SQL::
+* Replication FAQ::
+* Replication Problems::
+@end menu
+
+@node Replication Features, Replication Options, Replication HOWTO, Replication HOWTO
+@subsection Replication Features and Known Problems
+
+@cindex options, replication
+@cindex @code{my.cnf} file
+@cindex files,@code{my.cnf}
+
+Below is an explanation of what is supported and what is not:
+
+@itemize @bullet
+@item
+Replication will be done correctly with @code{AUTO_INCREMENT},
+@code{LAST_INSERT_ID}, and @code{TIMESTAMP} values.
+@item
+@code{RAND()} in updates does not replicate properly. Use
+@code{RAND(some_non_rand_expr)} if you are replicating updates with
+@code{RAND()}. You can, for example, use @code{UNIX_TIMESTAMP()} for the
+argument to @code{RAND()}.
+@item
+You have to use the same character set (@code{--default-character-set})
+on the master and the slave. If not, you may get duplicate key errors on
+the slave, because a key that is regarded as unique on the master may
+not be that in the other character set.
+@item
+@code{LOAD DATA INFILE} will be handled properly as long as the file
+still resides on the master server at the time of update
+propagation. @code{LOAD LOCAL DATA INFILE} will be skipped.
+@item
+Update queries that use user variables are not replication-safe (yet).
+@item
+@code{FLUSH} commands are not stored in the binary log and are because
+of this not replicated to the slaves. This is not normally a problem as
+@code{FLUSH} doesn't change anything. This does however mean that if you
+update the @code{MySQL} privilege tables directly without using
+@code{GRANT} statement and you replicate the @code{MySQL} privilege
+database, you must do a @code{FLUSH PRIVILEGES} on your slaves to put
+the new privileges into effect.
+@item
+Temporary tables starting in 3.23.29 are replicated properly with the
+exception of the case when you shut down slave server ( not just slave thread),
+you have some temporary tables open, and the are used in subsequent updates.
+To deal with this problem, to shut down the slave, do @code{SLAVE STOP}, then
+check @code{Slave_open_temp_tables} variable to see if it is 0, then issue
+@code{mysqladmin shutdown}. If the number is not 0, restart the slave thread
+with @code{SLAVE START} and see
+if you have better luck next time. There will be a cleaner solution, but it
+has to wait until version 4.0.
+In earlier versions temporary tables are not being replicated properly - we
+recommend that you either upgrade, or execute @code{SET SQL_LOG_BIN=0} on
+your clients before all queries with temp tables.
+@item
+@strong{MySQL} only supports one master and many slaves. We will in 4.x
+add a voting algorithm to automatically change master if something goes
+wrong with the current master. We will also introduce 'agent' processes
+to help doing load balancing by sending select queries to different
+slaves.
+@item
+Starting in Version 3.23.26, it is safe to connect servers in a circular
+master-slave relationship with @code{log-slave-updates} enabled.
+Note, however, that many queries will not work right in this kind of
+setup unless your client code is written to take care of the potential
+problems that can happen from updates that occur in different sequence
+on different servers.
+
+This means that you can do a setup like the following:
+
+@example
+A -> B -> C -> A
+@end example
+
+This setup will only works if you only do non conflicting updates
+between the tables. In other words, if you insert data in A and C, you
+should never insert a row in A that may have a conflicting key with a
+row insert in C. You should also not update the sam rows on two servers
+if the order in which the updates are applied matters.
+
+Note that the log format has changed in Version 3.23.26 so that
+pre-3.23.26 slaves will not be able to read it.
+@item
+If the query on the slave gets an error, the slave thread will
+terminate, and a message will appear in the @code{.err} file. You should
+then connect to the slave manually, fix the cause of the error (for
+example, non-existent table), and then run @code{SLAVE START} sql
+command (available starting in Version 3.23.16). In Version 3.23.15, you
+will have to restart the server.
+@item
+If connection to the master is lost, the slave will retry immediately,
+and then in case of failure every @code{master-connect-retry} (default
+60) seconds. Because of this, it is safe to shut down the master, and
+then restart it after a while. The slave will also be able to deal with
+network connectivity outages.
+@item
+Shutting down the slave (cleanly) is also safe, as it keeps track of
+where it left off. Unclean shutdowns might produce problems, especially
+if disk cache was not synced before the system died. Your system fault
+tolerance will be greatly increased if you have a good UPS.
+@item
+If the master is listening on a non-standard port, you will also need to
+specify this with @code{master-port} parameter in @code{my.cnf} .
+@item
+In Version 3.23.15, all of the tables and databases will be
+replicated. Starting in Version 3.23.16, you can restrict replication to
+a set of databases with @code{replicate-do-db} directives in
+@code{my.cnf} or just exclude a set of databases with
+@code{replicate-ignore-db}. Note that up until Version 3.23.23, there was a bug
+that did not properly deal with @code{LOAD DATA INFILE} if you did it in
+a database that was excluded from replication.
+@item
+Starting in Version 3.23.16, @code{SET SQL_LOG_BIN = 0} will turn off
+replication (binary) logging on the master, and @code{SET SQL_LOG_BIN =
+1} will turn in back on - you must have the process privilege to do
+this.
+@item
+Starting in Version 3.23.19, you can clean up stale replication leftovers when
+something goes wrong and you want a clean start with @code{FLUSH MASTER}
+and @code{FLUSH SLAVE} commands. In Version 3.23.26 we have renamed them to
+@code{RESET MASTER} and @code{RESET SLAVE} respectively to clarify
+what they do. The old @code{FLUSH} variants still work, though, for
+compatibility.
+
+@item
+Starting in Version 3.23.21, you can use @code{LOAD TABLE FROM MASTER} for
+network backup and to set up replication initially. We have recently
+received a number of bug reports concerning it that we are investigating, so
+we recommend that you use it only in testing until we make it more stable.
+@item
+Starting in Version 3.23.23, you can change masters and adjust log position
+with @code{CHANGE MASTER TO}.
+@item
+Starting in Version 3.23.23, you tell the master that updates in certain
+databases should not be logged to the binary log with @code{binlog-ignore-db}.
+@item
+Starting in Version 3.23.26, you can use @code{replicate-rewrite-db} to tell
+the slave to apply updates from one database on the master to the one
+with a different name on the slave.
+@item
+Starting in Version 3.23.28, you can use @code{PURGE MASTER LOGS TO 'log-name'}
+to get rid of old logs while the slave is running.
+@end itemize
+
+
+@node Replication Options, Replication SQL, Replication Features, Replication HOWTO
+@subsection Replication Options in my.cnf
+
+If you are using replication, we recommend you to use @strong{MySQL} Version
+3.23.30 or later. Older versions work, but they do have some bugs and are
+missing some features.
+
+On both master and slave you need to use the @code{server-id} option.
+This sets an unique replication id. You should pick a unique value in the
+range between 1 to 2^32-1 for each master and slave.
+Example: @code{server-id=3}
+
+The following table has the options you can use for the @strong{MASTER}:
+
+@multitable @columnfractions .3 .7
+
+@item @strong{Option} @tab @strong{Description}
+@item @code{log-bin=filename} @tab
+Write to a binary update log to the specified location. Note that if you
+give it a parameter with an extension (for example,
+@code{log-bin=/mysql/logs/replication.log} ) versions up to 3.23.24 will
+not work right during replication if you do @code{FLUSH LOGS} . The
+problem is fixed in Version 3.23.25. If you are using this kind of log
+name, @code{FLUSH LOGS} will be ignored on binlog. To clear the log, run
+@code{FLUSH MASTER}, and do not forget to run @code{FLUSH SLAVE} on all
+slaves. In Version 3.23.26 and in later versions you should use
+@code{RESET MASTER} and @code{RESET SLAVE}
+
+@item @code{log-bin-index=filename} @tab
+Because the user could issue the @code{FLUSH LOGS} command, we need to
+know which log is currently active and which ones have been rotated out
+and in what sequence. This information is stored in the binary log index file.
+The default is `hostname`.index. You can use this option if you want to
+be a rebel. (Example: @code{log-bin-index=db.index})
+
+@item @code{sql-bin-update-same} @tab
+If set, setting @code{SQL_LOG_BIN} to a value will automatically set
+@code{SQL_LOG_UPDATE} to the same value and vice versa.
+
+@item @code{binlog-do-db=database_name} @tab
+Tells the master it should log updates for the specified database, and
+exclude all others not explicitly mentioned.
+(Example: @code{binlog-do-db=some_database})
+
+@item @code{binlog-ignore-db=database_name} @tab
+Tells the master that updates to the given database should not be logged
+to the binary log (Example: @code{binlog-ignore-db=some_database})
+@end multitable
+
+The following table has the options you can use for the @strong{SLAVE}:
+
+@multitable @columnfractions .3 .7
+
+@item @strong{Option} @tab @strong{Description}
+@item @code{master-host=host} @tab
+Master hostname or IP address for replication. If not set, the slave
+thread will not be started.
+(Example: @code{master-host=db-master.mycompany.com})
+
+@item @code{master-user=username} @tab
+The user the slave thread will us for authentication when connecting to
+the master. The user must have @code{FILE} privilege. If the master user
+is not set, user @code{test} is assumed. (Example:
+@code{master-user=scott})
+
+@item @code{master-password=password} @tab
+The password the slave thread will authenticate with when connecting to
+the master. If not set, an empty password is assumed. (Example:
+@code{master-password=tiger})
+
+@item @code{master-port=portnumber} @tab
+The port the master is listening on. If not set, the compiled setting of
+@code{MYSQL_PORT} is assumed. If you have not tinkered with
+@code{configure} options, this should be 3306. (Example:
+@code{master-port=3306})
+
+@item @code{master-connect-retry=seconds} @tab
+The number of seconds the slave thread will sleep before retrying to
+connect to the master in case the master goes down or the connection is
+lost. Default is 60. (Example: @code{master-connect-retry=60})
+
+@item @code{master-info-file=filename} @tab
+The location of the file that remembers where we left off on the master
+during the replication process. The default is master.info in the data
+directory. Sasha: The only reason I see for ever changing the default
+is the desire to be rebelious. (Example:
+@code{master-info-file=master.info})
+
+@item @code{replicate-do-table=db_name.table_name} @tab
+Tells the slave thread to restrict replication to the specified database.
+To specify more than one table, use the directive multiple times,
+once for each table. .
+(Example: @code{replicate-do-table=some_db.some_table})
+
+@item @code{replicate-ignore-table=db_name.table_name} @tab
+Tells the slave thread to not replicate to the specified table. To
+specify more than one table to ignore, use the directive multiple
+times, once for each table.(Example:
+@code{replicate-ignore-table=db_name.some_table})
+
+@item @code{replicate-wild-do-table=db_name.table_name} @tab
+Tells the slave thread to restrict replication to the tables that match the
+specified wildcard pattern. .
+To specify more than one table, use the directive multiple times,
+once for each table. .
+(Example: @code{replicate-do-table=foo%.bar%} will replicate only updates
+to tables in all databases that start with foo and whose table names
+start with bar)
+
+@item @code{replicate-wild-ignore-table=db_name.table_name} @tab
+Tells the slave thread to not replicate to the tables that match the given
+wild card pattern. To
+specify more than one table to ignore, use the directive multiple
+times, once for each table.(Example:
+@code{replicate-ignore-table=foo%.bar%} - will not upates to tables in all databases that start with foo and whose table names
+start with bar)
+
+@item @code{replicate-ignore-db=database_name} @tab
+Tells the slave thread to not replicate to the specified database. To
+specify more than one database to ignore, use the directive multiple
+times, once for each database. This option will not work if you use cross
+database updates. If you need cross database updates to work, make sure
+you have 3.23.28 or later, and use
+@code{replicate-wild-ignore-table=db_name.%}(Example:
+@code{replicate-ignore-db=some_db})
+
+@item @code{replicate-do-db=database_name} @tab
+Tells the slave thread to restrict replication to the specified database.
+To specify more than one database, use the directive multiple times,
+once for each database. Note that this will only work if you do not use
+cross-database queries such as @code{UPDATE some_db.some_table SET
+foo='bar'} while having selected a different or no database. If you need
+cross database updates to work, make sure
+you have 3.23.28 or later, and use
+@code{replicate-wild-do-table=db_name.%}
+(Example: @code{replicate-do-db=some_db})
+
+@item @code{log-slave-updates} @tab
+Tells the slave to log the updates from the slave thread to the binary
+log. Off by default. You will need to turn it on if you plan to
+daisy-chain the slaves.
+
+@item @code{replicate-rewrite-db=from_name->to_name} @tab
+Updates to a database with a different name than the original (Example:
+@code{replicate-rewrite-db=master_db_name->slave_db_name}
+
+@item @code{skip-slave-start} @tab
+Tells the slave server not to start the slave on the startup. The user
+can start it later with @code{SLAVE START}.
+
+@item @code{slave_read_timeout=#}
+Number of seconds to wait for more data from the master before aborting
+the read.
+@end multitable
+
+
+@node Replication SQL, Replication FAQ, Replication Options, Replication HOWTO
+@subsection SQL Commands Related to Replication
+
+@cindex SQL commands, replication
+@cindex commands, replication
+@cindex replication, commands
+
+Replication can be controlled through the SQL interface. Below is the
+summary of commands:
+
+@multitable @columnfractions .30 .70
+@item @strong{Command} @tab @strong{Description}
+
+@item @code{SLAVE START}
+ @tab Starts the slave thread. (Slave)
+
+@item @code{SLAVE STOP}
+ @tab Stops the slave thread. (Slave)
+
+@item @code{SET SQL_LOG_BIN=0}
+ @tab Disables update logging if the user has process privilege.
+ Ignored otherwise. (Master)
+
+@item @code{SET SQL_LOG_BIN=1}
+ @tab Re-enables update logging if the user has process privilege.
+ Ignored otherwise. (Master)
+
+@item @code{SET SQL_SLAVE_SKIP_COUNTER=n}
+ @tab Skip the next @code{n} events from the master. Only valid when
+the slave thread is not running, otherwise, gives an error. Useful for
+recovering from replication glitches.
+
+@item @code{RESET MASTER}
+ @tab Deletes all binary logs listed in the index file, resetting the binlog
+index file to be empty. In pre-3.23.26 versions, @code{FLUSH MASTER} (Master)
+
+@item @code{RESET SLAVE}
+ @tab Makes the slave forget its replication position in the master
+logs. In pre 3.23.26 versions the command was called
+@code{FLUSH SLAVE}(Slave)
+
+@item @code{LOAD TABLE tblname FROM MASTER}
+ @tab Downloads a copy of the table from master to the slave. (Slave)
+
+@item @code{CHANGE MASTER TO master_def_list}
+ @tab Changes the master parameters to the values specified in
+@code{master_def_list} and restarts the slave thread. @code{master_def_list}
+is a comma-separated list of @code{master_def} where @code{master_def} is
+one of the following: @code{MASTER_HOST}, @code{MASTER_USER},
+@code{MASTER_PASSWORD}, @code{MASTER_PORT}, @code{MASTER_CONNECT_RETRY},
+@code{MASTER_LOG_FILE}, @code{MASTER_LOG_POS}. Example:
+
+@example
+
+CHANGE MASTER TO
+ MASTER_HOST='master2.mycompany.com',
+ MASTER_USER='replication',
+ MASTER_PASSWORD='bigs3cret',
+ MASTER_PORT=3306,
+ MASTER_LOG_FILE='master2-bin.001',
+ MASTER_LOG_POS=4;
+
+@end example
+
+You only need to specify the values that need to be changed. The values that
+you omit will stay the same with the exception of when you change the host or
+the port. In that case, the slave will assume that since you are connecting to
+a different host or a different port, the master is different. Therefore, the
+old values of log and position are not applicable anymore, and will
+automatically be reset to an empty string and 0, respectively (the start
+values). Note that if you restart the slave, it will remember its last master.
+If this is not desirable, you should delete the @file{master.info} file before
+restarting, and the slave will read its master from @code{my.cnf} or the
+command line. (Slave)
+
+@item @code{SHOW MASTER STATUS} @tab Provides status information on the binlog of the master. (Master)
+
+@item @code{SHOW SLAVE STATUS} @tab Provides status information on essential parameters of the slave thread. (Slave)
+@item @code{SHOW MASTER LOGS} @tab Only available starting in Version 3.23.28. Lists the binary logs on the master. You should use this command prior to @code{PURGE MASTER LOGS TO} to find out how far you should go.
+
+@item @code{PURGE MASTER LOGS TO 'logname'}
+ @tab Available starting in Version 3.23.28. Deletes all the
+replication logs that are listed in the log
+index as being prior to the specified log, and removed them from the
+log index, so that the given log now becomes first. Example:
+
+@example
+PURGE MASTER LOGS TO 'mysql-bin.010'
+@end example
+
+This command will do nothing and fail with an error if you have an
+active slave that is currently reading one of the logs you are trying to
+delete. However, if you have a dormant slave, and happen to purge one of
+the logs it wants to read, the slave will be unable to replicate once it
+comes up. The command is safe to run while slaves are replicating - you
+do not need to stop them.
+
+You must first check all the slaves with @code{SHOW SLAVE STATUS} to
+see which log they are on, then do a listing of the logs on the
+master with @code{SHOW MASTER LOGS}, find the earliest log among all
+the slaves (if all the slaves are up to date, this will be the
+last log on the list), backup all the logs you are about to delete
+(optional) and purge up to the target log.
+
+@end multitable
+
+
+@node Replication FAQ, Replication Problems, Replication SQL, Replication HOWTO
+@subsection Replication FAQ
+
+@cindex @code{Binlog_Dump}
+@strong{Q}: Why do I sometimes see more than one @code{Binlog_Dump} thread on
+the master after I have restarted the slave?
+
+@strong{A}: @code{Binlog_Dump} is a continuous process that is handled by the
+server in the following way:
+
+@itemize @bullet
+@item
+Catch up on the updates.
+@item
+Once there are no more updates left, go into @code{pthread_cond_wait()},
+from which we can be awakened either by an update or a kill.
+@item
+On wake up, check the reason. If we are not supposed to die, continue
+the @code{Binlog_dump} loop.
+@item
+If there is some fatal error, such as detecting a dead client,
+terminate the loop.
+@end itemize
+
+So if the slave thread stops on the slave, the corresponding
+@code{Binlog_Dump} thread on the master will not notice it until after
+at least one update to the master (or a kill), which is needed to wake
+it up from @code{pthread_cond_wait()}. In the meantime, the slave
+could have opened another connection, which resulted in another
+@code{Binlog_Dump} thread.
+
+The above problem should not be present in Version 3.23.26 and later
+versions. In Version 3.23.26 we added @code{server-id} to each
+replication server, and now all the old zombie threads are killed on the
+master when a new replication thread connects from the same slave
+
+@strong{Q}: How do I rotate replication logs?
+
+@strong{A}: In Version 3.23.28 you should use @code{PURGE MASTER LOGS
+TO} command after determining which logs can be deleted, and optionally
+backing them up first. In earlier versions the process is much more
+painful, and cannot be safely done without stopping all the slaves in
+the case that you plan to re-use log names. You will need to stop the
+slave threads, edit the binary log index file, delete all the old logs,
+restart the master, start slave threads, and then remove the old log files.
+
+
+@strong{Q}: How do I upgrade on a hot replication setup?
+
+@strong{A}: If you are upgrading pre-3.23.26 versions, you should just
+lock the master tables, let the slave catch up, then run @code{FLUSH
+MASTER} on the master, and @code{FLUSH SLAVE} on the slave to reset the
+logs, then restart new versions of the master and the slave. Note that
+the slave can stay down for some time - since the master is logging
+all the updates, the slave will be able to catch up once it is up and
+can connect.
+
+After 3.23.26, we have locked the replication protocol for modifications, so
+you can upgrade masters and slave on the fly to a newer 3.23 version and you
+can have different versions of @strong{MySQL} running on the slave and the
+master, as long as they are both newer than 3.23.26.
+
+@cindex replication, two-way
+@strong{Q}: What issues should I be aware of when setting up two-way
+replication?
+
+@strong{A}: @strong{MySQL} replication currently does not support any
+locking protocol between master and slave to guarantee the atomicity of
+a distributed (cross-server) update. In in other words, it is possible
+for client A to make an update to co-master 1, and in the meantime,
+before it propagates to co-master 2, client B could make an update to
+co-master 2 that will make the update of client A work differently than
+it did on co-master 1. Thus when the update of client A will make it
+to co-master 2, it will produce tables that will be different than
+what you have on co-master 1, even after all the updates from co-master
+2 have also propagated. So you should not co-chain two servers in a
+two-way replication relationship, unless you are sure that you updates
+can safely happen in any order, or unless you take care of mis-ordered
+updates somehow in the client code.
+
+
+You must also realize that two-way replication actually does not improve
+performance very much, if at all, as far as updates are concerned. Both
+servers need to do the same amount of updates each, as you would have
+one server do. The only difference is that there will be a little less
+lock contention, because the updates originating on another server will
+be serialized in one slave thread. This benefit, though, might be
+offset by network delays.
+
+@cindex performance, improving
+@cindex increasing, performance
+@strong{Q}: How can I use replication to improve performance of my system?
+
+@strong{A}: You should set up one server as the master, and direct all
+writes to it, and configure as many slaves as you have the money and
+rackspace for, distributing the reads among the master and the slaves.
+You can also start the slaves with @code{--skip-bdb},
+@code{--low-priority-updates} and @code{--delay-key-write-for-all-tables}
+to get speed improvements for the slave. In this case the slave will
+use non-transactional @code{MyISAM} tables instead of @code{BDB} tables
+to get more speed.
+
+@strong{Q}: What should I do to prepare my client code to use
+performance-enhancing replication?
+
+@strong{A}:
+If the part of your code that is responsible for database access has
+been properly abstracted/modularized, converting it to run with the
+replicated setup should be very smooth and easy - just change the
+implementation of your database access to read from some slave or the
+master, and to always write to the master. If your code does not have
+this level of abstraction,
+setting up a replicated system will give you an opportunity/motivation
+to it clean up.
+ You should start by creating a wrapper library
+/module with the following functions:
+
+@itemize
+@item
+@code{safe_writer_connect()}
+@item
+@code{safe_reader_connect()}
+@item
+@code{safe_reader_query()}
+@item
+@code{safe_writer_query()}
+@end itemize
+
+@code{safe_} means that the function will take care of handling all
+the error conditions.
+
+You should then convert your client code to use the wrapper library.
+It may be a painful and scary process at first, but it will pay off in
+the long run. All applications that follow the above pattern will be
+able to take advantage of one-master/many slaves solution. The
+code will be a lot easier to maintain, and adding troubleshooting
+options will be trivial. You will just need to modify one or two
+functions, for example, to log how long each query took, or which
+query, among your many thousands, gave you an error. If you have written a lot of code already,
+you may want to automate the conversion task by using Monty's
+@code{replace} utility, which comes with the standard distribution of
+@strong{MySQL}, or just write your own Perl script. Hopefully, your
+code follows some recognizable pattern. If not, then you are probably
+better off re-writing it anyway, or at least going through and manually
+beating it into a pattern.
+
+Note that, of course, you can use different names for the
+functions. What is important is having unified interface for connecting
+for reads, connecting for writes, doing a read, and doing a write.
+
+
+@strong{Q}: When and how much can @strong{MySQL} replication improve the performance
+of my system?
+
+@strong{A}: @strong{MySQL} replication is most beneficial for a system
+with frequent reads and not so frequent writes. In theory, by using a
+one master/many slaves setup you can scale by adding more slaves until
+you either run out of network bandwidth, or your update
+load grows to the point
+that the master cannot handle it.
+
+In order to determine how many slaves you can get before the added
+benefits begin to level out, and how much you can improve performance
+of your site, you need to know your query patterns, and empirically
+ (by benchmarking) determine the relationship between the throughput
+on reads (reads per second, or @code{max_reads}) and on writes
+@code{max_writes}) on a typical master and a typical slave. The
+example below will show you a rather simplified calculation of what you
+can get with replication for our imagined system.
+
+Let's say our system load consists of 10% writes and 90% reads, and we
+have determined that @code{max_reads} = 1200 - 2 * @code{max_writes},
+or in other words, our system can do 1200 reads per second with no
+writes, our average write is twice as slow as average read,
+and the relationship is
+linear. Let us suppose that our master and slave are of the same
+capacity, and we have N slaves and 1 master. Then we have for each
+server (master or slave):
+
+@code{reads = 1200 - 2 * writes} (from bencmarks)
+
+@code{reads = 9* writes / (N + 1) } (reads split, but writes go
+to all servers)
+
+@code{9*writes/(N+1) + 2 * writes = 1200}
+
+@code{writes = 1200/(2 + 9/(N+1)}
+
+So if N = 0, which means we have no replication, our system can handle
+1200/11, about 109 writes per second (which means we will have 9 times
+as many reads due to the nature of our application).
+
+If N = 1, we can get up to 184 writes per second.
+
+If N = 8, we get up to 400.
+
+If N = 17, 480 writes.
+
+Eventually as N approaches infinity (and our budget negative infinity),
+we can get very close to 600 writes per second, increasing system
+throughput about 5.5 times. However, with only 8 servers, we increased
+it almost 4 times already.
+
+Note that our computations assumed infinite network bandwidth, and
+neglected several other factors that could turn out to be significant on
+your system. In many cases, you may not be able to make a computation
+similar to the one above that will accurately predict what will happen
+on your system if you add N replication slaves. However, answering the
+following questions should help you decided whether and how much, if at
+all, the replication will improve the performance of your system:
+
+@itemize @bullet
+@item
+What is the read/write ratio on your system?
+@item
+How much more write load can one server handle if you reduce the reads?
+@item
+How many slaves do you have bandwidth for on your network?
+@end itemize
+
+@strong{Q}: How can I use replication to provide redundancy/high
+availability?
+
+@strong{A}: With the currently available features, you would have to
+set up a master and a slave (or several slaves), and write a script
+that will monitor the
+master to see if it is up, and instruct your applications and
+the slaves of the master change in case of failure. Some suggestions:
+
+@itemize @bullet
+@item
+To tell a slave to change the master use the @code{CHANGE MASTER TO} command.
+@item
+A good way to keep your applications informed where the master is by
+having a dynamic DNS entry for the master. With @strong{bind} you can
+use @code{nsupdate} to dynamically update your DNS.
+@item
+You should run your slaves with the @code{log-bin} option and without
+@code{log-slave-updates}. This way the slave will be ready to become a
+master as soon as you issue @code{STOP SLAVE}; @code{RESET MASTER}, and
+@code{CHANGE MASTER TO} on the other slaves. It will also help you catch
+spurious updates that may happen because of misconfiguration of the
+slave (ideally, you want to configure access rights so that no client
+can update the slave, except for the slave thread) combined with the
+bugs in your client programs (they should never update the slave
+directly).
+
+@end itemize
+
+We are currently working on integrating an automatic master election
+system into @strong{MySQL}, but until it is ready, you will have to
+create your own monitoring tools.
+
+
+@node Replication Problems, , Replication FAQ, Replication HOWTO
+@subsection Troubleshooting Replication
+
+If you have followed the instructions, and your replication setup is not
+working, first eliminate the user error factor by checking the following:
+
+@itemize @bullet
+@item
+Is the master logging to the binary log? Check with @code{SHOW MASTER STATUS}.
+If it is, @code{Position} will be non-zero. If not, verify that you have
+given the master @code{log-bin} option and have set @code{server-id}.
+@item
+Is the slave running? Check with @code{SHOW SLAVE STATUS}. The answer is found
+in @code{Slave_running} column. If not, verify slave options and check the
+error log for messages.
+@item
+If the slave is running, did it establish connection with the master? Do
+@code{SHOW PROCESSLIST}, find the thread with @code{system user} value in
+@code{User} column and @code{none} in the @code{Host} column, and check the
+@code{State} column. If it says @code{connecting to master}, verify the
+privileges for the replication user on the master, master host name, your
+DNS setup, whether the master is actually running, whether it is reachable
+from the slave, and if all that seems ok, read the error logs.
+@item
+If the slave was running, but then stopped, look at SHOW SLAVE STATUS
+output and check the error logs. It usually
+happens when some query that succeeded on the master fails on the slave. This
+should never happen if you have taken a proper snapshot of the master, and
+never modify the data on the slave outside of the slave thread. If it does,
+it is a bug, read below on how to report it.
+@item
+If a query on that succeeded on the master refuses to run on the slave, and
+a full database resync ( the proper thing to do ) does not seem feasible,
+try the following:
+@itemize bullet
+@item
+First see if there is some stray record in the way. Understand how it got
+there, then delete it and run @code{SLAVE START}
+@item
+If the above does not work or does not apply, try to understand if it would
+be safe to make the update manually ( if needed) and then ignore the next
+query from the master.
+@item
+If you have decided you can skip the next query, do
+@code{SET SQL_SLAVE_SKIP_COUNTER=1; SLAVE START;} to skip a query that
+does not use auto_increment, or last_insert_id or
+@code{SET SQL_SLAVE_SKIP_COUNTER=2; SLAVE START;} otherwise. The reason
+auto_increment/last_insert_id queries are different is that they take
+two events in the binary log of the master.
+
+@item
+If you are sure the slave started out perfectly in sync with the master,
+and no one has updated the tables involved outside of slave thread,
+report the bug, so
+you will not have to do the above tricks again.
+@end itemize
+@item
+Make sure you are not running into an old bug by upgrading to the most recent
+version.
+@item
+If all else fails, read the error logs. If they are big,
+@code{grep -i slave /path/to/your-log.err} on the slave. There is no
+generic pattern to search for on the master, as the only errors it logs
+are general system errors - if it can, it will send the error to the slave
+when things go wrong.
+@end itemize
+
+When you have determined that there is no user error involved, and replication
+still either does not work at all or is unstable, it is time to start working
+on a bug report. We need to get as much info as possible from you to be able
+to track down the bug. Please do spend some time and effort preparing a good
+bug report. Ideally, we would like to have a test case in the format found in
+@code{mysql-test/t/rpl*} directory of the source tree. If you submit a test
+case like that, you can expect a patch within a day or two in most cases,
+although, of course, you mileage may vary depending on a number of factors.
+
+Second best option is a just program with easily configurable connection
+arguments for the master and the slave that will demonstrate the problem on our
+systems. You can write one in Perl or in C, depending on which language you
+know better.
+
+If you have one of the above ways to demonstrate the bug, use
+@code{mysqlbug} to prepare a bug report and send it to
+@email{bugs@@lists.mysql.com}. If you have a phantom - a problem that
+does occur but you cannot duplicate "at will":
+
+@itemize @bullet
+@item
+Verify that there is no user error involved. For example, if you update the
+slave outside of the slave thread, the data will be out of sync, and you can
+have unique key violations on updates, in which case the slave thread will
+stop and wait for you to clean up the tables manually to bring them in sync.
+@item
+Run slave with @code{log-slave-updates} and @code{log-bin} - this will keep
+a log of all updates on the slave.
+@item
+Save all evidence before resetting the replication. If we have no or only
+sketchy information, it would take us a while to track down the problem. The
+evidence you should collect is:
+@itemize @bullet
+@item
+All binary logs on the master
+@item
+All binary log on the slave
+@item
+The output of @code{SHOW MASTER STATUS} on the master at the time
+you have discovered the problem
+@item
+The output of @code{SHOW SLAVE STATUS} on the master at the time
+you have discovered the problem
+@item
+Error logs on the master and on the slave
+@end itemize
+@item
+Use @code{mysqlbinlog} to examine the binary logs. The following should
+be helpful
+to find the trouble query, for example:
+@example
+mysqlbinlog -j pos_from_slave_status /path/to/log_from_slave_status | head
+@end example
@end itemize
-@node Reference, Table types, Privilege system, Top
+Once you have collected the evidence on the phantom problem, try hard to
+isolate it into a separate test case first. Then report the problem to
+@email{bugs@@lists.mysql.com} with as much info as possible.
+
+
+
+@node Reference, Table types, MySQL Database Administration, Top
@chapter MySQL Language Reference
@menu
@@ -16397,12 +23635,6 @@ to restart @code{mysqld} with @code{--skip-grant-tables} to run
* ALTER TABLE:: @code{ALTER TABLE} syntax
* RENAME TABLE:: @code{RENAME TABLE} syntax
* DROP TABLE:: @code{DROP TABLE} syntax
-* OPTIMIZE TABLE:: @code{OPTIMIZE TABLE} syntax
-* CHECK TABLE:: @code{CHECK TABLE} syntax
-* BACKUP TABLE:: @code{BACKUP TABLE} syntax
-* RESTORE TABLE:: @code{RESTORE TABLE} syntax
-* ANALYZE TABLE:: @code{ANALYZE TABLE} syntax
-* REPAIR TABLE:: @code{REPAIR TABLE} syntax
* DELETE:: @code{DELETE} syntax
* TRUNCATE:: @code{TRUNCATE} syntax
* SELECT:: @code{SELECT} syntax
@@ -16412,16 +23644,12 @@ to restart @code{mysqld} with @code{--skip-grant-tables} to run
* LOAD DATA:: @code{LOAD DATA INFILE} syntax
* UPDATE:: @code{UPDATE} syntax
* USE:: @code{USE} syntax
-* FLUSH:: @code{FLUSH} syntax (clearing caches)
-* KILL:: @code{KILL} syntax
-* SHOW:: @code{SHOW} syntax (Get information about tables, columns, ...)
* EXPLAIN:: @code{EXPLAIN} syntax (Get information about a @code{SELECT})
* DESCRIBE:: @code{DESCRIBE} syntax (Get information about names of columns)
* COMMIT:: @code{BEGIN/COMMIT/ROLLBACK} syntax
* LOCK TABLES:: @code{LOCK TABLES/UNLOCK TABLES} syntax
* SET OPTION:: @code{SET OPTION} syntax
* SET TRANSACTION:: @code{SET TRANSACTION} syntax
-* GRANT:: @code{GRANT} and @code{REVOKE} syntax
* CREATE INDEX:: @code{CREATE INDEX} syntax
* DROP INDEX:: @code{DROP INDEX} syntax
* Comments:: Comment syntax
@@ -16436,13 +23664,15 @@ effectively. This chapter also serves as a reference to all functionality
included in @strong{MySQL}. In order to use this chapter effectively, you
may find it useful to refer to the various indexes.
+
+@node Literals, Variables, Reference, Reference
+@section Literals: How to Write Strings and Numbers
+
@cindex strings, defined
@cindex strings, escaping characters
@cindex literals
@cindex escape characters
@cindex backslash, escape character
-@node Literals, Variables, Reference, Reference
-@section Literals: How to Write Strings and Numbers
@menu
* String syntax:: Strings
@@ -21167,7 +28397,7 @@ only creates a directory under the @strong{MySQL} data directory.
@cindex @code{mysqladmin}
You can also create databases with @code{mysqladmin}.
-@xref{Programs}.
+@xref{Client-Side Scripts}.
@findex DROP DATABASE
@node DROP DATABASE, CREATE TABLE, CREATE DATABASE, Reference
@@ -21204,7 +28434,7 @@ In @strong{MySQL} Version 3.22 or later, you can use the keywords
exist.
@cindex @code{mysqladmin}
-You can also drop databases with @code{mysqladmin}. @xref{Programs}.
+You can also drop databases with @code{mysqladmin}. @xref{Client-Side Scripts}.
@findex CREATE TABLE
@node CREATE TABLE, ALTER TABLE, DROP DATABASE, Reference
@@ -22010,7 +29240,7 @@ will do a reverse rename for all renamed tables to get everything back
to the original state.
@findex DROP TABLE
-@node DROP TABLE, OPTIMIZE TABLE, RENAME TABLE, Reference
+@node DROP TABLE, DELETE, RENAME TABLE, Reference
@section @code{DROP TABLE} Syntax
@example
@@ -22030,295 +29260,11 @@ For the moment they don't do anything.
@strong{NOTE}: @code{DROP TABLE} is not transaction-safe and will
automatically commit any active transactions.
-@cindex tables, defragment
-@cindex tables, fragmentation
-@findex OPTIMIZE TABLE
-@node OPTIMIZE TABLE, CHECK TABLE, DROP TABLE, Reference
-@section @code{OPTIMIZE TABLE} Syntax
-
-@example
-OPTIMIZE TABLE tbl_name[,tbl_name]...
-@end example
-
-@code{OPTIMIZE TABLE} should be used if you have deleted a large part of a
-table or if you have made many changes to a table with variable-length rows
-(tables that have @code{VARCHAR}, @code{BLOB}, or @code{TEXT} columns).
-Deleted records are maintained in a linked list and subsequent @code{INSERT}
-operations reuse old record positions. You can use @code{OPTIMIZE TABLE} to
-reclaim the unused space and to defragment the data file.
-
-For the moment @code{OPTIMIZE TABLE} only works on @strong{MyISAM} and
-@code{BDB} tables. For @code{BDB} tables, @code{OPTIMIZE TABLE} is
-currently mapped to @code{ANALYZE TABLE}. @xref{ANALYZE TABLE}.
-
-You can get optimize table to work on other table types by starting
-@code{mysqld} with @code{--skip-new} or @code{--safe-mode}, but in this
-case @code{OPTIMIZE TABLE} is just mapped to @code{ALTER TABLE}.
-
-@code{OPTIMIZE TABLE} works the following way:
-@itemize @bullet
-@item
-If the table has deleted or split rows, repair the table.
-@item
-If the index pages are not sorted, sort them.
-@item
-If the statistics are not up to date (and the repair couldn't be done
-by sorting the index), update them.
-@end itemize
-
-@code{OPTIMIZE TABLE} for @code{MyISAM} tables is equvialent of running
-@code{myisamchk --quick --check-changed-tables --sort-index --analyze}
-on the table.
-
-Note that the table is locked during the time @code{OPTIMIZE TABLE} is
-running!
-
-@findex CHECK TABLE
-@node CHECK TABLE, BACKUP TABLE, OPTIMIZE TABLE, Reference
-@section @code{CHECK TABLE} Syntax
-
-@example
-CHECK TABLE tbl_name[,tbl_name...] [option [option...]]
-
-option = QUICK | FAST | MEDIUM | EXTEND | CHANGED
-@end example
-
-@code{CHECK TABLE} only works on @code{MyISAM} tables. On
-@code{MyISAM} tables it's the same thing as running @code{myisamchk -m
-table_name} on the table.
-
-If you don't specify any option @code{MEDIUM} is used.
-
-Checks the table(s) for errors. For @code{MyISAM} tables the key statistics
-is updated. The command returns a table with the following columns:
-
-@multitable @columnfractions .35 .65
-@item @strong{Column} @tab @strong{Value}
-@item Table @tab Table name.
-@item Op @tab Always ``check''.
-@item Msg_type @tab One of @code{status}, @code{error}, @code{info}, or @code{warning}.
-@item Msg_text @tab The message.
-@end multitable
-
-Note that you can get many rows of information for each checked
-table. The last row will be of @code{Msg_type status} and should
-normally be @code{OK}. If you don't get @code{OK}, or @code{Not
-checked} you should normally run a repair of the table. @xref{Table
-maintenance}. @code{Not checked} means that the table the given @code{TYPE}
-told @strong{MySQL} that there wasn't any need to check the table.
-
-The different check types stand for the following:
-
-@multitable @columnfractions .20 .80
-@item @strong{Type} @tab @strong{Meaning}
-@item @code{QUICK} @tab Don't scan the rows to check for wrong links.
-@item @code{FAST} @tab Only check tables which haven't been closed properly.
-@item @code{CHANGED} @tab Only check tables which have been changed since last check or haven't been closed properly.
-@item @code{MEDIUM} @tab Scan rows to verify that deleted links are ok. This also calculates a key checksum for the rows and verifies this with a calcualted checksum for the keys.
-@item @code{EXTENDED} @tab Do a full key lookup for all keys for each row. This ensures that the table is 100 % consistent, but will take a long time!
-@end multitable
-
-For dynamic sized @code{MyISAM} tables a started check will always
-do a @code{MEDIUM} check. For static size rows we skip the row scan
-for @code{QUICK} and @code{FAST} as the rows are very seldom corrupted.
-
-You can combine check options as in:
-
-@example
-CHECK TABLE test_table FAST QUICK;
-@end example
-
-Which only would do a quick check on the table if it wasn't closed properly.
-
-@strong{NOTE:} that in some case @code{CHECK TABLE} will change the
-table! This happens if the table is marked as 'corrupted' or 'not
-closed properly' but @code{CHECK TABLE} didn't find any problems in the
-table. In this case @code{CHECK TABLE} will mark the table as ok.
-
-If a table is corrupted, then it's most likely that the problem is in
-the indexes and not in the data part. All of the above check types
-checks the indexes throughly and should thus find most errors.
-
-If you just want to check a table that you assume is ok, you should use
-no check options or the @code{QUICK} option. The later should be used
-when you are in a hurry and can take the very small risk that
-@code{QUICK} didn't find an error in the data file (In most cases
-@strong{MySQL} should find, under normal usage, any error in the data
-file. If this happens then the table will be marked as 'corrupted',
-in which case the table can't be used until it's repaired).
-
-@code{FAST} and @code{CHANGED} are mostly intended to be used from a
-script (for example to be executed from cron) if you want to check your
-table from time to time. In most cases you @code{FAST} is to be prefered
-over @code{CHANGED}. (The only case when it isn't is when you suspect a
-bug you have found a bug in the @code{MyISAM} code.).
-
-@code{EXTENDED} is only to be used after you have run a normal check but
-still get strange errors from a table when @strong{MySQL} tries to
-update a row or find a row by key (this is VERY unlikely to happen if a
-normal check has succeeded!).
-
-Some things reported by check table, can't be corrected automatically:
-
-@itemize @bullet
-@item
-@code{Found row where the auto_increment column has the value 0}.
-
-This means that you have in the table a row where the
-@code{auto_increment} index column contains the value 0.
-(It's possible to create a row where the auto_increment column is 0 by
-explicitely setting the column to 0 with an @code{UPDATE} statement)
-
-This isn't an error in itself, but could cause trouble if you decide to
-dump the table and restore it or do an @code{ALTER TABLE} on the
-table. In this case the auto_increment column will change value,
-according to the rules of auto_increment columns, which could cause
-problems like a duplicate key error.
-
-To get rid of the warning, just execute an @code{UPDATE} statement
-to set the column to some other value than 0.
-@end itemize
-
-
-@findex BACKUP TABLE
-@node BACKUP TABLE, RESTORE TABLE, CHECK TABLE, Reference
-@section @code{BACKUP TABLE} Syntax
-
-@example
-BACKUP TABLE tbl_name[,tbl_name...] TO '/path/to/backup/directory'
-@end example
-
-Make a copy of all the table files to the backup directory that are the
-minimum needed to restore it. Currenlty only works for @code{MyISAM}
-tables. For @code{MyISAM} table, copies @code{.frm} (definition) and
-@code{.MYD} (data) files. The index file can be rebuilt from those two.
-
-Before using this command, please see @xref{Backup}.
-
-During the backup, read lock will be held for each table, one at time,
-as they are being backed up. If you want to backup several tables as
-a snapshot, you must first issue @code{LOCK TABLES} obtaining a read
-lock for each table in the group.
-
-The command returns a table with the following columns:
-
-@multitable @columnfractions .35 .65
-@item @strong{Column} @tab @strong{Value}
-@item Table @tab Table name
-@item Op @tab Always ``backup''
-@item Msg_type @tab One of @code{status}, @code{error}, @code{info} or @code{warning}.
-@item Msg_text @tab The message.
-@end multitable
-
-Note that @code{BACKUP TABLE} is only available in @strong{MySQL}
-version 3.23.25 and later.
-
-@findex RESTORE TABLE
-@node RESTORE TABLE, ANALYZE TABLE, BACKUP TABLE, Reference
-@section @code{RESTORE TABLE} Syntax
-
-@example
-RESTORE TABLE tbl_name[,tbl_name...] FROM '/path/to/backup/directory'
-@end example
-
-Restores the table(s) from the backup that was made with
-@code{BACKUP TABLE}. Existing tables will not be overwritten - if you
-try to restore over an existing table, you will get an error. Restore
-will take longer than BACKUP due to the need to rebuilt the index. The
-more keys you have, the longer it is going to take. Just as
-@code{BACKUP TABLE}, currently only works of @code{MyISAM} tables.
-
-
-The command returns a table with the following columns:
-@multitable @columnfractions .35 .65
-@item @strong{Column} @tab @strong{Value}
-@item Table @tab Table name
-@item Op @tab Always ``restore''
-@item Msg_type @tab One of @code{status}, @code{error}, @code{info} or @code{warning}.
-@item Msg_text @tab The message.
-@end multitable
-
-
-@findex ANALYZE TABLE
-@node ANALYZE TABLE, REPAIR TABLE, RESTORE TABLE, Reference
-@section @code{ANALYZE TABLE} Syntax
-
-@example
-ANALYZE TABLE tbl_name[,tbl_name...]
-@end example
-
-Analyze and store the key distribution for the table. During the
-analyze the table is locked with a read lock. This works on
-@code{MyISAM} and @code{BDB} tables.
-
-This is equivalent to running @code{myisamchk -a} on the table.
-
-@strong{MySQL} uses the stored key distribution to decide in which order
-tables should be joined when one does a join on something else than a
-constant.
-
-The command returns a table with the following columns:
-
-@multitable @columnfractions .35 .65
-@item @strong{Column} @tab @strong{Value}
-@item Table @tab Table name
-@item Op @tab Always ``analyze''
-@item Msg_type @tab One of @code{status}, @code{error}, @code{info} or @code{warning}.
-@item Msg_text @tab The message.
-@end multitable
-
-You can check the stored key distribution with the @code{SHOW INDEX} command.
-@xref{SHOW DATABASE INFO}.
-
-If the table hasn't changed since the last @code{ANALYZE TABLE} command,
-the table will not be analyzed again.
-
-@findex REPAIR TABLE
-@node REPAIR TABLE, DELETE, ANALYZE TABLE, Reference
-@section @code{REPAIR TABLE} Syntax
-
-@example
-REPAIR TABLE tbl_name[,tbl_name...] [QUICK] [EXTENDED]
-@end example
-
-@code{REPAIR TABLE} only works on @code{MyISAM} tables and is the same
-as running @code{myisamchk -r table_name} on the table.
-
-Normally you should never have to run this command, but if disaster strikes
-you are very likely to get back all your data from a MyISAM table with
-@code{REPAIR TABLE}. If your tables get corrupted a lot you should
-try to find the reason for this! @xref{Crashing}. @xref{MyISAM table problems}.
-
-@code{REPAIR TABLE} repairs a possible corrupted table. The command returns a
-table with the following columns:
-
-@multitable @columnfractions .35 .65
-@item @strong{Column} @tab @strong{Value}
-@item Table @tab Table name
-@item Op @tab Always ``repair''
-@item Msg_type @tab One of @code{status}, @code{error}, @code{info} or @code{warning}.
-@item Msg_text @tab The message.
-@end multitable
-
-Note that you can get many rows of information for each repaired
-table. The last one row will be of @code{Msg_type status} and should
-normally be @code{OK}. If you don't get @code{OK}, you should try
-repairing the table with @code{myisamchk -o}, as @code{REPAIR TABLE}
-does not yet implement all the options of @code{myisamchk}. In the near
-future, we will make it more flexible.
-
-If @code{QUICK} is given then @strong{MySQL} will try to do a
-@code{REPAIR} of only the index tree.
-
-If you use @code{EXTENDED} then @strong{MySQL} will create the index row
-by row instead of creating one index at a time with sorting; This may be
-better than sorting on fixed-length keys if you have long @code{char()}
-keys that compress very good.
+@node DELETE, TRUNCATE, DROP TABLE, Reference
+@section @code{DELETE} Syntax
@findex DELETE
-@node DELETE, TRUNCATE, REPAIR TABLE, Reference
-@section @code{DELETE} Syntax
@example
DELETE [LOW_PRIORITY] FROM tbl_name
@@ -23712,7 +30658,7 @@ In @strong{MySQL} Version 3.23, you can use @code{LIMIT #} to ensure that
only a given number of rows are changed.
@findex USE
-@node USE, FLUSH, UPDATE, Reference
+@node USE, EXPLAIN, UPDATE, Reference
@section @code{USE} Syntax
@example
@@ -23746,1054 +30692,10 @@ mysql> SELECT author_name,editor_name FROM author,db2.editor
@cindex compatibility, with Sybase
The @code{USE} statement is provided for Sybase compatibility.
-@cindex @code{mysqladmin}
-@cindex clearing, caches
-@cindex caches, clearing
-@findex FLUSH
-@node FLUSH, KILL, USE, Reference
-@section @code{FLUSH} Syntax
-
-@example
-FLUSH flush_option [,flush_option]
-@end example
-
-You should use the @code{FLUSH} command if you want to clear some of the
-internal caches @strong{MySQL} uses. To execute @code{FLUSH}, you must have
-the @strong{RELOAD} privilege.
-
-@code{flush_option} can be any of the following:
-
-@multitable @columnfractions .15 .85
-@item @code{HOSTS} @tab Empties the host cache tables. You should flush the
-host tables if some of your hosts change IP number or if you get the
-error message @code{Host ... is blocked}. When more than
-@code{max_connect_errors} errors occur in a row for a given host while
-connection to the @strong{MySQL} server, @strong{MySQL} assumes
-something is wrong and blocks the host from further connection requests.
-Flushing the host tables allows the host to attempt to connect
-again. @xref{Blocked host}.) You can start @code{mysqld} with
-@code{-O max_connection_errors=999999999} to avoid this error message.
-
-@item @code{LOGS} @tab Closes and reopens all log files.
-If you have specified the update log file or a binary log file without
-an extension, the extension number of the log file will be incremented
-by one relative to the previous file. If you have used an extension in
-the file name, @strong{MySQL} will close and reopen the update log file.
-@xref{Update log}. This is the same thing as sending the @code{SIGHUP}
-signal to the @code{mysqld} server.
-
-@item @code{PRIVILEGES} @tab Reloads the privileges from the grant tables in
-the @code{mysql} database.
-
-@item @code{TABLES} @tab Closes all open tables and force all tables in use to be closed.
-
-@item @code{[TABLE | TABLES] table_name [,table_name...]} @tab Flushes only the given tables.
-
-@item @code{TABLES WITH READ LOCK} @tab Closes all open tables and locks all tables for all databases with a read until one executes @code{UNLOCK TABLES}. This is very convenient way to get backups if you have a file system, like Veritas,that can take snapshots in time.
-
-@item @code{STATUS} @tab Resets most status variables to zero. This is something one should only use when debugging a query.
-@end multitable
-
-You can also access each of the commands shown above with the @code{mysqladmin}
-utility, using the @code{flush-hosts}, @code{flush-logs}, @code{reload},
-or @code{flush-tables} commands.
-
-Take also a look at the @code{RESET} command used with
-replication. @xref{Replication SQL}.
-
-@cindex @code{mysqladmin}
-@findex KILL
-@node KILL, SHOW, FLUSH, Reference
-@section @code{KILL} Syntax
-
-@example
-KILL thread_id
-@end example
-
-Each connection to @code{mysqld} runs in a separate thread. You can see
-which threads are running with the @code{SHOW PROCESSLIST} command and kill
-a thread with the @code{KILL thread_id} command.
-
-If you have the @strong{process} privilege, you can see and kill all threads.
-Otherwise, you can see and kill only your own threads.
-
-You can also use the @code{mysqladmin processlist} and @code{mysqladmin kill}
-commands to examine and kill threads.
-
-When you do a @code{KILL}, a thread specific @code{kill flag} is set for
-the thread.
-
-In most cases it may take some time for the thread to die as the kill
-flag is only checked at specific intervals.
-
-@itemize @bullet
-@item
-In @code{SELECT}, @code{ORDER BY} and @code{GROUP BY} loops, the flag is
-checked after reading a block of rows. If the kill flag is set the
-statement is aborted
-@item
-When doing an @code{ALTER TABLE} the kill flag is checked before each block of
-rows are read from the original table. If the kill flag was set the command
-is aborted and the temporary table is deleted.
-@item
-When doing an @code{UPDATE TABLE} and @code{DELETE TABLE}, the kill flag
-is checked after each block read and after each updated or delete
-row. If the kill flag is set the statement is aborted. Note that if you
-are not using transactions, the changes will not be rolled back!
-@item
-@code{GET_LOCK()} will abort with @code{NULL}.
-@item
-An @code{INSERT DELAYED} thread will quickly flush all rows it has in
-memory and die.
-@item
-If the thread is in the table lock handler (state: @code{Locked}),
-the table lock will be quickly aborted.
-@item
-If the thread is waiting for free disk space in a @code{write} call, the
-write is aborted with an disk full error message.
-@end itemize
-
-@findex SHOW DATABASES
-@findex SHOW TABLES
-@findex SHOW COLUMNS
-@findex SHOW FIELDS
-@findex SHOW INDEX
-@findex SHOW KEYS
-@findex SHOW STATUS
-@findex SHOW VARIABLES
-@findex SHOW PROCESSLIST
-@findex SHOW TABLE STATUS
-@findex SHOW GRANTS
-@findex SHOW CREATE TABLE
-@findex SHOW MASTER STATUS
-@findex SHOW MASTER LOGS
-@findex SHOW SLAVE STATUS
-@node SHOW, EXPLAIN, KILL, Reference
-@section @code{SHOW} Syntax
-
-@example
- SHOW DATABASES [LIKE wild]
-or SHOW [OPEN] TABLES [FROM db_name] [LIKE wild]
-or SHOW [FULL] COLUMNS FROM tbl_name [FROM db_name] [LIKE wild]
-or SHOW INDEX FROM tbl_name [FROM db_name]
-or SHOW TABLE STATUS [FROM db_name] [LIKE wild]
-or SHOW STATUS [LIKE wild]
-or SHOW VARIABLES [LIKE wild]
-or SHOW LOGS
-or SHOW [FULL] PROCESSLIST
-or SHOW GRANTS FOR user
-or SHOW CREATE TABLE table_name
-or SHOW MASTER STATUS
-or SHOW MASTER LOGS
-or SHOW SLAVE STATUS
-@end example
-
-@code{SHOW} provides information about databases, tables, columns, or
-status information about the server. If the @code{LIKE wild} part is
-used, the @code{wild} string can be a string that uses the SQL @samp{%}
-and @samp{_} wild-card characters.
-
-@findex SHOW DATABASES
-@findex SHOW TABLES
-@findex SHOW COLUMNS
-@findex SHOW FIELDS
-@findex SHOW INDEX
-@findex SHOW KEYS
-@menu
-* SHOW DATABASE INFO::
-* SHOW TABLE STATUS::
-* SHOW STATUS::
-* SHOW VARIABLES::
-* SHOW LOGS::
-* SHOW PROCESSLIST::
-* SHOW GRANTS::
-* SHOW CREATE TABLE::
-@end menu
-
-@cindex displaying, information, @code{SHOW}
-@node SHOW DATABASE INFO, SHOW TABLE STATUS, SHOW, SHOW
-@subsection @code{SHOW} Information About Databases, Tables, Columns, and Indexes
-
-You can use @code{db_name.tbl_name} as an alternative to the @code{tbl_name
-FROM db_name} syntax. These two statements are equivalent:
-
-@example
-mysql> SHOW INDEX FROM mytable FROM mydb;
-mysql> SHOW INDEX FROM mydb.mytable;
-@end example
-
-@code{SHOW DATABASES} lists the databases on the @strong{MySQL} server
-host. You can also get this list using the @code{mysqlshow} command.
-
-@code{SHOW TABLES} lists the tables in a given database. You can also
-get this list using the @code{mysqlshow db_name} command.
-
-@strong{NOTE:} If a user doesn't have any privileges for a table, the table
-will not show up in the output from @code{SHOW TABLES} or @code{mysqlshow
-db_name}.
-
-@code{SHOW OPEN TABLES} lists the tables that are currently open in
-the table cache. @xref{Table cache}. The @code{Comment} field tells
-how many times the table is @code{cached} and @code{in_use}.
-
-@code{SHOW COLUMNS} lists the columns in a given table. If you specify
-the @code{FULL} option, you will also get the privileges you have for
-each column. If the column types are different than you expect them to
-be based on a @code{CREATE TABLE} statement, note that @strong{MySQL}
-sometimes changes column types. @xref{Silent column changes}.
-
-The @code{DESCRIBE} statement provides information similar to
-@code{SHOW COLUMNS}.
-@xref{DESCRIBE, , @code{DESCRIBE}}.
-
-@code{SHOW FIELDS} is a synonym for @code{SHOW COLUMNS}, and
-@code{SHOW KEYS} is a synonym for @code{SHOW INDEX}. You can also
-list a table's columns or indexes with @code{mysqlshow db_name tbl_name}
-or @code{mysqlshow -k db_name tbl_name}.
-
-@code{SHOW INDEX} returns the index information in a format that closely
-resembles the @code{SQLStatistics} call in ODBC. The following columns
-are returned:
-
-@multitable @columnfractions .35 .65
-@item @strong{Column} @tab @strong{Meaning}
-@item @code{Table} @tab Name of the table.
-@item @code{Non_unique} @tab 0 if the index can't contain duplicates.
-@item @code{Key_name} @tab Name of the index.
-@item @code{Seq_in_index} @tab Column sequence number in index,
- starting with 1.
-@item @code{Column_name} @tab Column name.
-@item @code{Collation} @tab How the column is sorted in the index.
- In @strong{MySQL}, this can have values
- @samp{A} (Ascending) or @code{NULL} (Not
- sorted).
-@item @code{Cardinality} @tab Number of unique values in the index.
- This is updated by running
- @code{isamchk -a}.
-@item @code{Sub_part} @tab Number of indexed characters if the
- column is only partly indexed.
- @code{NULL} if the entire key is indexed.
-@item @code{Comment} @tab Various remarks. For now, it tells
- whether index is FULLTEXT or not.
-@end multitable
-
-Note that as the @code{Cardinality} is counted based on statistics
-stored as integers, it's not necessarily accurate for small tables.
-
-@cindex displaying, table status
-@cindex tables, displaying status
-@cindex status, tables
-@node SHOW TABLE STATUS, SHOW STATUS, SHOW DATABASE INFO, SHOW
-@subsection @code{SHOW TABLE STATUS}
-
-@example
-SHOW TABLE STATUS [FROM db_name] [LIKE wild]
-@end example
-
-@code{SHOW TABLE STATUS} (new in Version 3.23) works likes @code{SHOW
-STATUS}, but provides a lot of information about each table. You can
-also get this list using the @code{mysqlshow --status db_name} command.
-The following columns are returned:
-
-@multitable @columnfractions .30 .70
-@item @strong{Column} @tab @strong{Meaning}
-@item @code{Name} @tab Name of the table.
-@item @code{Type} @tab Type of table. @xref{Table types}.
-@item @code{Row_format} @tab The row storage format (Fixed, Dynamic, or Compressed).
-@item @code{Rows} @tab Number of rows.
-@item @code{Avg_row_length} @tab Average row length.
-@item @code{Data_length} @tab Length of the data file.
-@item @code{Max_data_length} @tab Max length of the data file.
-@item @code{Index_length} @tab Length of the index file.
-@item @code{Data_free} @tab Number of allocated but not used bytes.
-@item @code{Auto_increment} @tab Next autoincrement value.
-@item @code{Create_time} @tab When the table was created.
-@item @code{Update_time} @tab When the data file was last updated.
-@item @code{Check_time} @tab When the table was last checked.
-@item @code{Create_options} @tab Extra options used with @code{CREATE TABLE}.
-@item @code{Comment} @tab The comment used when creating the table (or some information why @strong{MySQL} couldn't access the table information).
-@end multitable
-
-@code{InnoDB} tables will report the free space in the tablespace
-in the table comment.
-
-@node SHOW STATUS, SHOW VARIABLES, SHOW TABLE STATUS, SHOW
-@subsection @code{SHOW STATUS}
-
-@cindex @code{mysqladmin}
-@code{SHOW STATUS} provides server status information
-(like @code{mysqladmin extended-status}). The output resembles that shown
-below, though the format and numbers probably differ:
-
-@example
-+--------------------------+------------+
-| Variable_name | Value |
-+--------------------------+------------+
-| Aborted_clients | 0 |
-| Aborted_connects | 0 |
-| Bytes_received | 155372598 |
-| Bytes_sent | 1176560426 |
-| Connections | 30023 |
-| Created_tmp_disk_tables | 0 |
-| Created_tmp_tables | 8340 |
-| Created_tmp_files | 60 |
-| Delayed_insert_threads | 0 |
-| Delayed_writes | 0 |
-| Delayed_errors | 0 |
-| Flush_commands | 1 |
-| Handler_delete | 462604 |
-| Handler_read_first | 105881 |
-| Handler_read_key | 27820558 |
-| Handler_read_next | 390681754 |
-| Handler_read_prev | 6022500 |
-| Handler_read_rnd | 30546748 |
-| Handler_read_rnd_next | 246216530 |
-| Handler_update | 16945404 |
-| Handler_write | 60356676 |
-| Key_blocks_used | 14955 |
-| Key_read_requests | 96854827 |
-| Key_reads | 162040 |
-| Key_write_requests | 7589728 |
-| Key_writes | 3813196 |
-| Max_used_connections | 0 |
-| Not_flushed_key_blocks | 0 |
-| Not_flushed_delayed_rows | 0 |
-| Open_tables | 1 |
-| Open_files | 2 |
-| Open_streams | 0 |
-| Opened_tables | 44600 |
-| Questions | 2026873 |
-| Select_full_join | 0 |
-| Select_full_range_join | 0 |
-| Select_range | 99646 |
-| Select_range_check | 0 |
-| Select_scan | 30802 |
-| Slave_running | OFF |
-| Slave_open_temp_tables | 0 |
-| Slow_launch_threads | 0 |
-| Slow_queries | 0 |
-| Sort_merge_passes | 30 |
-| Sort_range | 500 |
-| Sort_rows | 30296250 |
-| Sort_scan | 4650 |
-| Table_locks_immediate | 1920382 |
-| Table_locks_waited | 0 |
-| Threads_cached | 0 |
-| Threads_created | 30022 |
-| Threads_connected | 1 |
-| Threads_running | 1 |
-| Uptime | 80380 |
-+--------------------------+------------+
-@end example
-
-@cindex variables, status
-The status variables listed above have the following meaning:
-
-@multitable @columnfractions .35 .65
-@item @strong{Variable} @tab @strong{Meaning}
-@item @code{Aborted_clients} @tab Number of connections aborted because the client died without closing the connection properly. @xref{Communication errors}.
-@item @code{Aborted_connects} @tab Number of tries to connect to the @strong{MySQL} server that failed. @xref{Communication errors}.
-@item @code{Bytes_received} @tab Number of bytes received from all clients.
-@item @code{Bytes_sent} @tab Number of bytes sent to all clients.
-@item @code{Connections} @tab Number of connection attempts to the @strong{MySQL} server.
-@item @code{Created_tmp_disk_tables} @tab Number of implicit temporary tables on disk created while executing statements.
-@item @code{Created_tmp_tables} @tab Number of implicit temporary tables in memory created while executing statements.
-@item @code{Created_tmp_files} @tab How many temporary files @code{mysqld} have created.
-@item @code{Delayed_insert_threads} @tab Number of delayed insert handler threads in use.
-@item @code{Delayed_writes} @tab Number of rows written with @code{INSERT DELAYED}.
-@item @code{Delayed_errors} @tab Number of rows written with @code{INSERT DELAYED} for which some error occurred (probably @code{duplicate key}).
-@item @code{Flush_commands} @tab Number of executed @code{FLUSH} commands.
-@item @code{Handler_delete} @tab Number of times a row was deleted from a table.
-@item @code{Handler_read_first} @tab Number of times the first entry was read from an index.
-If this is high, it suggests that the server is doing a lot of full index scans, for example,
-@code{SELECT col1 FROM foo}, assuming that col1 is indexed.
-@item @code{Handler_read_key} @tab Number of requests to read a row based on a key. If this
-is high, it is a good indication that your queries and tables are properly indexed.
-@item @code{Handler_read_next} @tab Number of requests to read next row in key order. This
-will be incremented if you are querying an index column with a range constraint. This also
-will be incremented if you are doing an index scan.
-@item @code{Handler_read_rnd} @tab Number of requests to read a row based on a fixed position.
-This will be high if you are doing a lot of queries that require sorting of the result.
-@item @code{Handler_read_rnd_next} @tab Number of requests to read the next row in the datafile.
-This will be high if you are doing a lot of table scans. Generally this suggests that your tables
-are not properly indexed or that your queries are not written to take advantage of the indexes you
-have.
-@item @code{Handler_update} @tab Number of requests to update a row in a table.
-@item @code{Handler_write} @tab Number of requests to insert a row in a table.
-@item @code{Key_blocks_used} @tab The number of used blocks in the key cache.
-@item @code{Key_read_requests} @tab The number of requests to read a key block from the cache.
-@item @code{Key_reads} @tab The number of physical reads of a key block from disk.
-@item @code{Key_write_requests} @tab The number of requests to write a key block to the cache.
-@item @code{Key_writes} @tab The number of physical writes of a key block to disk.
-@item @code{Max_used_connections} @tab The maximum number of connections in use simultaneously.
-@item @code{Not_flushed_key_blocks} @tab Keys blocks in the key cache that has changed but hasn't yet been flushed to disk.
-@item @code{Not_flushed_delayed_rows} @tab Number of rows waiting to be written in @code{INSERT DELAY} queues.
-@item @code{Open_tables} @tab Number of tables that are open.
-@item @code{Open_files} @tab Number of files that are open.
-@item @code{Open_streams} @tab Number of streams that are open (used mainly for logging).
-@item @code{Opened_tables} @tab Number of tables that have been opened.
-@item @code{Select_full_join} @tab Number of joins without keys (Should be 0).
-@item @code{Select_full_range_join} @tab Number of joins where we used a range search on reference table.
-@item @code{Select_range} @tab Number of joins where we used ranges on the first table. (It's normally not critical even if this is big.)
-@item @code{Select_scan} @tab Number of joins where we scanned the first table.
-@item @code{Select_range_check} @tab Number of joins without keys where we check for key usage after each row (Should be 0).
-@item @code{Questions} @tab Number of queries sent to the server.
-@item @code{Slave_open_temp_tables} @tab Number of temporary tables currently
-open by the slave thread
-@item @code{Slow_launch_threads} @tab Number of threads that have taken more than @code{slow_launch_time} to connect.
-@item @code{Slow_queries} @tab Number of queries that have taken more than @code{long_query_time}. @xref{Slow query log}.
-@item @code{Sort_merge_passes} @tab Number of merges the sort has to do. If this value is large you should consider increasing @code{sort_buffer}.
-@item @code{Sort_range} @tab Number of sorts that where done with ranges.
-@item @code{Sort_rows} @tab Number of sorted rows.
-@item @code{Sort_scan} @tab Number of sorts that where done by scanning the table.
-@item @code{Table_locks_immediate} @tab Number of times a table lock was
-acquired immediately. Available after 3.23.33.
-@item @code{Table_locks_waited} @tab Number of times a table lock could not
-be acquired immediately and a wait was needed. If this is high, and you
-have performance problems, you should first optimize your queries, and then
-either split your table(s) or use replication. Available after 3.23.33.
-@item @code{Threads_cached} @tab Number of threads in the thread cache.
-@item @code{Threads_connected} @tab Number of currently open connections.
-@item @code{Threads_created} @tab Number of threads created to handle connections.
-@item @code{Threads_running} @tab Number of threads that are not sleeping.
-@item @code{Uptime} @tab How many seconds the server has been up.
-@end multitable
-
-Some comments about the above:
-
-@itemize @bullet
-@item
-If @code{Opened_tables} is big, then your @code{table_cache}
-variable is probably too small.
-@item
-If @code{key_reads} is big, then your @code{key_cache} is probably too
-small. The cache hit rate can be calculated with
-@code{key_reads}/@code{key_read_requests}.
-@item
-If @code{Handler_read_rnd} is big, then you probably have a lot of
-queries that require @strong{MySQL} to scan whole tables or you have
-joins that don't use keys properly.
-@item
-If @code{Threads_created} is big, you may want to increase the
-@code{thread_cache_size} variable.
-@end itemize
-
-@node SHOW VARIABLES, SHOW LOGS, SHOW STATUS, SHOW
-@subsection @code{SHOW VARIABLES}
-
-@example
-SHOW VARIABLES [LIKE wild]
-@end example
-
-@code{SHOW VARIABLES} shows the values of some @strong{MySQL} system
-variables. You can also get this information using the @code{mysqladmin
-variables} command. If the default values are unsuitable, you can set most
-of these variables using command-line options when @code{mysqld} starts up.
-@xref{Command-line options}.
-
-The output resembles that shown below, though the format and numbers may
-differ somewhat:
-
-@example
-+-------------------------+---------------------------+
-| Variable_name | Value |
-+-------------------------+---------------------------+
-| ansi_mode | OFF |
-| back_log | 50 |
-| basedir | /my/monty/ |
-| bdb_cache_size | 16777216 |
-| bdb_log_buffer_size | 32768 |
-| bdb_home | /my/monty/data/ |
-| bdb_max_lock | 10000 |
-| bdb_logdir | |
-| bdb_shared_data | OFF |
-| bdb_tmpdir | /tmp/ |
-| binlog_cache_size | 32768 |
-| concurrent_insert | ON |
-| connect_timeout | 5 |
-| datadir | /my/monty/data/ |
-| delay_key_write | ON |
-| delayed_insert_limit | 100 |
-| delayed_insert_timeout | 300 |
-| delayed_queue_size | 1000 |
-| flush | OFF |
-| flush_time | 0 |
-| have_bdb | YES |
-| have_innodb | YES |
-| have_raid | YES |
-| have_ssl | NO |
-| init_file | |
-| interactive_timeout | 28800 |
-| join_buffer_size | 131072 |
-| key_buffer_size | 16776192 |
-| language | /my/monty/share/english/ |
-| large_files_support | ON |
-| log | OFF |
-| log_update | OFF |
-| log_bin | OFF |
-| log_slave_updates | OFF |
-| long_query_time | 10 |
-| low_priority_updates | OFF |
-| lower_case_table_names | 0 |
-| max_allowed_packet | 1048576 |
-| max_binlog_cache_size | 4294967295 |
-| max_connections | 100 |
-| max_connect_errors | 10 |
-| max_delayed_threads | 20 |
-| max_heap_table_size | 16777216 |
-| max_join_size | 4294967295 |
-| max_sort_length | 1024 |
-| max_tmp_tables | 32 |
-| max_write_lock_count | 4294967295 |
-| myisam_recover_options | DEFAULT |
-| myisam_sort_buffer_size | 8388608 |
-| net_buffer_length | 16384 |
-| net_read_timeout | 30 |
-| net_retry_count | 10 |
-| net_write_timeout | 60 |
-| open_files_limit | 0 |
-| pid_file | /my/monty/data/donna.pid |
-| port | 3306 |
-| protocol_version | 10 |
-| record_buffer | 131072 |
-| query_buffer_size | 0 |
-| safe_show_database | OFF |
-| server_id | 0 |
-| skip_locking | ON |
-| skip_networking | OFF |
-| skip_show_database | OFF |
-| slow_launch_time | 2 |
-| socket | /tmp/mysql.sock |
-| sort_buffer | 2097116 |
-| table_cache | 64 |
-| table_type | MYISAM |
-| thread_cache_size | 4 |
-| thread_stack | 65536 |
-| tmp_table_size | 1048576 |
-| tmpdir | /tmp/ |
-| version | 3.23.29a-gamma-debug |
-| wait_timeout | 28800 |
-+-------------------------+---------------------------+
-@end example
-
-Each option is described below. Values for buffer sizes, lengths, and stack
-sizes are given in bytes. You can specify values with a suffix of @samp{K}
-or @samp{M} to indicate kilobytes or megabytes. For example, @code{16M}
-indicates 16 megabytes. The case of suffix letters does not matter;
-@code{16M} and @code{16m} are equivalent:
-
-@cindex variables, values
-@table @code
-@item @code{ansi_mode}.
-Is @code{ON} if @code{mysqld} was started with @code{--ansi}.
-@xref{ANSI mode}.
-
-@item @code{back_log}
-The number of outstanding connection requests @strong{MySQL} can have. This
-comes into play when the main @strong{MySQL} thread gets @strong{VERY}
-many connection requests in a very short time. It then takes some time
-(although very little) for the main thread to check the connection and start
-a new thread. The @code{back_log} value indicates how many requests can be
-stacked during this short time before @strong{MySQL} momentarily stops
-answering new requests. You need to increase this only if you expect a large
-number of connections in a short period of time.
-
-In other words, this value is the size of the listen queue for incoming
-TCP/IP connections. Your operating system has its own limit on the size
-of this queue. The manual page for the Unix @code{listen(2)} system
-call should have more details. Check your OS documentation for the
-maximum value for this variable. Attempting to set @code{back_log}
-higher than your operating system limit will be ineffective.
-
-@item @code{basedir}
-The value of the @code{--basedir} option.
-
-@item @code{bdb_cache_size}
-The buffer that is allocated to cache index and rows for @code{BDB}
-tables. If you don't use @code{BDB} tables, you should start
-@code{mysqld} with @code{--skip-bdb} to not waste memory for this
-cache.
-
-@item @code{bdb_log_buffer_size}
-The buffer that is allocated to cache index and rows for @code{BDB}
-tables. If you don't use @code{BDB} tables, you should set this to 0 or
-start @code{mysqld} with @code{--skip-bdb} to not waste memory for this
-cache.
-
-@item @code{bdb_home}
-The value of the @code{--bdb-home} option.
-
-@item @code{bdb_max_lock}
-The maximum number of locks (1000 by default) you can have active on a
-BDB table. You should increase this if you get errors of type @code{bdb:
-Lock table is out of available locks} or @code{Got error 12 from ...}
-when you have do long transactions or when @code{mysqld} has to examine
-a lot of rows to calculate the query.
-
-@item @code{bdb_logdir}
-The value of the @code{--bdb-logdir} option.
-
-@item @code{bdb_shared_data}
-Is @code{ON} if you are using @code{--bdb-shared-data}.
-
-@item @code{bdb_tmpdir}
-The value of the @code{--bdb-tmpdir} option.
-
-@item @code{binlog_cache_size}. The size of the cache to hold the SQL
-statements for the binary log during a transaction. If you often use
-big, multi-statement transactions you can increase this to get more
-performance. @xref{COMMIT}.
-
-@item @code{character_set}
-The default character set.
-
-@item @code{character_sets}
-The supported character sets.
-
-@item @code{concurrent_inserts}
-If @code{ON} (the default), @strong{MySQL} will allow you to use @code{INSERT}
-on @code{MyISAM} tables at the same time as you run @code{SELECT} queries
-on them. You can turn this option off by starting @code{mysqld} with @code{--safe}
-or @code{--skip-new}.
-
-@cindex timeout
-@item @code{connect_timeout}
-The number of seconds the @code{mysqld} server is waiting for a connect
-packet before responding with @code{Bad handshake}.
-
-@item @code{datadir}
-The value of the @code{--datadir} option.
-
-@item @code{delay_key_write}
-If enabled (is on by default), @strong{MySQL} will honor the
-@code{delay_key_write} option @code{CREATE TABLE}. This means that the
-key buffer for tables with this option will not get flushed on every
-index update, but only when a table is closed. This will speed up
-writes on keys a lot, but you should add automatic checking of all tables
-with @code{myisamchk --fast --force} if you use this. Note that if you
-start @code{mysqld} with the @code{--delay-key-write-for-all-tables}
-option this means that all tables will be treated as if they were
-created with the @code{delay_key_write} option. You can clear this flag
-by starting @code{mysqld} with @code{--skip-new} or @code{--safe-mode}.
-
-@item @code{delayed_insert_limit}
-After inserting @code{delayed_insert_limit} rows, the @code{INSERT
-DELAYED} handler will check if there are any @code{SELECT} statements
-pending. If so, it allows these to execute before continuing.
-
-@item @code{delayed_insert_timeout}
-How long a @code{INSERT DELAYED} thread should wait for @code{INSERT}
-statements before terminating.
-
-@item @code{delayed_queue_size}
-What size queue (in rows) should be allocated for handling @code{INSERT
-DELAYED}. If the queue becomes full, any client that does @code{INSERT
-DELAYED} will wait until there is room in the queue again.
-
-@item @code{flush}
-This is @code{ON} if you have started @strong{MySQL} with the @code{--flush}
-option.
-
-@item @code{flush_time}
-If this is set to a non-zero value, then every @code{flush_time} seconds all
-tables will be closed (to free up resources and sync things to disk). We
-only recommend this option on Win95, Win98, or on systems where you have
-very little resources.
-
-@item @code{have_bdb}
-@code{YES} if @code{mysqld} supports Berkeley DB tables. @code{DISABLED}
-if @code{--skip-bdb} is used.
-@item @code{have_innodb}
-@code{YES} if @code{mysqld} supports InnoDB tables. @code{DISABLED}
-if @code{--skip-innodb} is used.
-@item @code{have_raid}
-@code{YES} if @code{mysqld} supports the @code{RAID} option.
-@item @code{have_ssl}
-@code{YES} if @code{mysqld} supports SSL (encryption) on the client/server
-protocol.
-
-@item @code{init_file}
-The name of the file specified with the @code{--init-file} option when
-you start the server. This is a file of SQL statements you want the
-server to execute when it starts.
-
-@item @code{interactive_timeout}
-The number of seconds the server waits for activity on an interactive
-connection before closing it. An interactive client is defined as a
-client that uses the @code{CLIENT_INTERACTIVE} option to
-@code{mysql_real_connect()}. See also @code{wait_timeout}.
-
-@item @code{join_buffer_size}
-The size of the buffer that is used for full joins (joins that do not
-use indexes). The buffer is allocated one time for each full join
-between two tables. Increase this value to get a faster full join when
-adding indexes is not possible. (Normally the best way to get fast joins
-is to add indexes.)
-
-@c Make texi2html support index @anchor{Index cache size}. Then change
-@c some xrefs to point here
-@cindex indexes, block size
-@item @code{key_buffer_size}
-Index blocks are buffered and are shared by all threads.
-@code{key_buffer_size} is the size of the buffer used for index blocks.
-
-Increase this to get better index handling (for all reads and multiple
-writes) to as much as you can afford; 64M on a 256M machine that mainly
-runs @strong{MySQL} is quite common. If you, however, make this too big
-(more than 50% of your total memory?) your system may start to page and
-become REALLY slow. Remember that because @strong{MySQL} does not cache
-data read, that you will have to leave some room for the OS filesystem
-cache.
-
-You can check the performance of the key buffer by doing @code{show
-status} and examine the variables @code{Key_read_requests},
-@code{Key_reads}, @code{Key_write_requests}, and @code{Key_writes}. The
-@code{Key_reads/Key_read_request} ratio should normally be < 0.01.
-The @code{Key_write/Key_write_requests} is usually near 1 if you are
-using mostly updates/deletes but may be much smaller if you tend to
-do updates that affect many at the same time or if you are
-using @code{delay_key_write}. @xref{SHOW}.
-
-To get even more speed when writing many rows at the same time, use
-@code{LOCK TABLES}. @xref{LOCK TABLES, , @code{LOCK TABLES}}.
-
-@item @code{language}
-The language used for error messages.
-
-@item @code{large_file_support}
-If @code{mysqld} was compiled with options for big file support.
-
-@item @code{locked_in_memory}
-If @code{mysqld} was locked in memory with @code{--memlock}
-
-@item @code{log}
-If logging of all queries is enabled.
-
-@item @code{log_update}
-If the update log is enabled.
-
-@item @code{log_bin}
-If the binary log is enabled.
-
-@item @code{log_slave_updates}
-If the updates from the slave should be logged.
-
-@item @code{long_query_time}
-If a query takes longer than this (in seconds), the @code{Slow_queries} counter
-will be incremented. If you are using @code{--log-slow-queries}, the query
-will be logged to the slow query logfile. @xref{Slow query log}.
-
-@item @code{lower_case_table_names}
-If set to 1 table names are stored in lowercase on disk. This will enable
-you to access the table names case-insensitive also on Unix.
-@xref{Name case sensitivity}.
-
-@item @code{max_allowed_packet}
-The maximum size of one packet. The message buffer is initialized to
-@code{net_buffer_length} bytes, but can grow up to @code{max_allowed_packet}
-bytes when needed. This value by default is small, to catch big (possibly
-wrong) packets. You must increase this value if you are using big
-@code{BLOB} columns. It should be as big as the biggest @code{BLOB} you want
-to use. The current protocol limits @code{max_allowed_packet} to 16M.
-
-@item @code{max_binlog_cache_size}
-If a multi-statement transaction requires more than this amount of memory,
-one will get the error "Multi-statement transaction required more than
-'max_binlog_cache_size' bytes of storage".
-
-@item @code{max_binlog_size}
-Available after 3.23.33. If a write to the binary (replication) log exceeds
-the given value, rotate the logs. You cannot set it to less than 1024 bytes,
-or more than 1 GB. Default is 1 GB.
-
-@item @code{max_connections}
-The number of simultaneous clients allowed. Increasing this value increases
-the number of file descriptors that @code{mysqld} requires. See below for
-comments on file descriptor limits. @xref{Too many connections}.
-
-@item @code{max_connect_errors}
-If there is more than this number of interrupted connections from a host
-this host will be blocked from further connections. You can unblock a host
-with the command @code{FLUSH HOSTS}.
-
-@item @code{max_delayed_threads}
-Don't start more than this number of threads to handle @code{INSERT DELAYED}
-statements. If you try to insert data into a new table after all @code{INSERT
-DELAYED} threads are in use, the row will be inserted as if the
-@code{DELAYED} attribute wasn't specified.
-
-@item @code{max_heap_table_size}
-Don't allow creation of heap tables bigger than this.
-
-@item @code{max_join_size}
-Joins that are probably going to read more than @code{max_join_size}
-records return an error. Set this value if your users tend to perform joins
-that lack a @code{WHERE} clause, that take a long time, and that return
-millions of rows.
-
-@item @code{max_sort_length}
-The number of bytes to use when sorting @code{BLOB} or @code{TEXT}
-values (only the first @code{max_sort_length} bytes of each value
-are used; the rest are ignored).
-
-@item @code{max_user_connections}
-The maximum number of active connections for a single user (0 = no limit).
-
-@item @code{max_tmp_tables}
-(This option doesn't yet do anything.)
-Maximum number of temporary tables a client can keep open at the same time.
-
-@item @code{max_write_lock_count}
-After this many write locks, allow some read locks to run in between.
-
-@item @code{myisam_recover_options}
-The value of the @code{--myisam-recover} option.
-
-@item @code{myisam_sort_buffer_size}
-The buffer that is allocated when sorting the index when doing a
-@code{REPAIR} or when creating indexes with @code{CREATE INDEX} or
-@code{ALTER TABLE}.
-
-@item @code{myisam_max_extra_sort_file_size}.
-If the creating of the temporary file for fast index creation would be
-this much bigger than using the key cache, then prefer the key cache
-method. This is mainly used to force long character keys in large
-tables to use the slower key cache method to create the index.
-@strong{NOTE} that this parameter is given in megabytes!
-
-@item @code{myisam_max_sort_file_size}
-The maximum size of the temporary file @strong{MySQL} is allowed to use
-while recreating the index (during @code{REPAIR}, @code{ALTER TABLE}
-or @code{LOAD DATA INFILE}. If the file size would be bigger than this,
-the index will be created through the key cache (which is slower).
-@strong{NOTE} that this parameter is given in megabytes!
-
-@item @code{net_buffer_length}
-The communication buffer is reset to this size between queries. This
-should not normally be changed, but if you have very little memory, you
-can set it to the expected size of a query. (That is, the expected length of
-SQL statements sent by clients. If statements exceed this length, the buffer
-is automatically enlarged, up to @code{max_allowed_packet} bytes.)
-
-@item @code{net_read_timeout}
-Number of seconds to wait for more data from a connection before aborting
-the read. Note that when we don't expect data from a connection, the timeout
-is defined by @code{write_timeout}. See also @code{slave_read_timeout}.
-
-@item @code{net_retry_count}
-If a read on a communication port is interrupted, retry this many times
-before giving up. This value should be quite high on @code{FreeBSD} as
-internal interrupts are sent to all threads.
-
-@item @code{net_write_timeout}
-Number of seconds to wait for a block to be written to a connection before
-aborting the write.
-
-@item @code{open_files_limit}
-If this is not 0, then @code{mysqld} will use this value to reserve file
-descriptors to use with @code{setrlimit()}. If this value is 0 then
-@code{mysqld} will reserve @code{max_connections*5} or
-@code{max_connections + table_cache*2} (whichever is larger) number of
-files. You should try increasing this if @code{mysqld} gives you the
-error 'Too many open files'.
-
-@item @code{pid_file}
-The value of the @code{--pid-file} option.
-
-@item @code{port}
-The value of the @code{--port} option.
-
-@item @code{protocol_version}
-The protocol version used by the @strong{MySQL} server.
-
-@item @code{record_buffer}
-Each thread that does a sequential scan allocates a buffer of this
-size for each table it scans. If you do many sequential scans, you may
-want to increase this value.
-
-@item @code{query_buffer_size}
-The initial allocation of the query buffer. If most of your queries are
-long (like when inserting blobs), you should increase this!
-
-@item @code{safe_show_databases}
-Don't show databases for which the user doesn't have any database or
-table privileges. This can improve security if you're concerned about
-people being able to see what databases other users have. See also
-@code{skip_show_databases}.
-
-@item @code{server_id}
-The value of the @code{--server-id} option.
-
-@item @code{skip_locking}
-Is OFF if @code{mysqld} uses external locking.
-
-@item @code{skip_networking}
-Is ON if we only allow local (socket) connections.
-
-@item @code{skip_show_databases}
-This prevents people from doing @code{SHOW DATABASES} if they don't have
-the @code{PROCESS_PRIV} privilege. This can improve security if you're
-concerned about people being able to see what databases other users
-have. See also @code{safe_show_databases}.
-
-@item @code{slave_read_timeout}
-Number of seconds to wait for more data from a master/slave connection
-before aborting the read.
-
-@item @code{slow_launch_time}
-If creating the thread takes longer than this value (in seconds), the
-@code{Slow_launch_threads} counter will be incremented.
-
-@item @code{socket}
-The Unix socket used by the server.
-
-@item @code{sort_buffer}
-Each thread that needs to do a sort allocates a buffer of this
-size. Increase this value for faster @code{ORDER BY} or @code{GROUP BY}
-operations.
-@xref{Temporary files}.
-
-@item @code{table_cache}
-The number of open tables for all threads. Increasing this value
-increases the number of file descriptors that @code{mysqld} requires.
-@strong{MySQL} needs two file descriptors for each unique open table.
-See below for comments on file descriptor limits. You can check if you
-need to increase the table cache by checking the @code{Opened_tables}
-variable. @xref{SHOW}. If this variable is big and you don't do
-@code{FLUSH TABLES} a lot (which just forces all tables to be closed and
-reopenend), then you should increase the value of this variable.
-
-Make sure that your operating system can handle the number of open file
-descriptors implied by the @code{table_cache} setting. If @code{table_cache}
-is set too high, @strong{MySQL} may run out of file descriptors and refuse
-connections, fail to perform queries, and be very unreliable.
-
-For information about how the table cache works, see @ref{Table cache}.
-
-@item @code{table_type}
-The default table type
-
-@item @code{thread_cache_size}
-How many threads we should keep in a cache for reuse. When a
-client disconnects, the client's threads are put in the cache if there
-aren't more than @code{thread_cache_size} threads from before. All new
-threads are first taken from the cache, and only when the cache is empty
-is a new thread created. This variable can be increased to improve
-performance if you have a lot of new connections. (Normally this doesn't
-give a notable performance improvement if you have a good
-thread implementation.) By examing the difference between
-the @code{Connections} and @code{Threads_created} you can see how efficient
-the current thread cache is for you.
-
-@item @code{thread_concurrency}
-On Solaris, @code{mysqld} will call @code{thr_setconcurrency()} with
-this value. @code{thr_setconcurrency()} permits the application to give
-the threads system a hint for the desired number of threads that should
-be run at the same time.
-
-@item @code{thread_stack}
-The stack size for each thread. Many of the limits detected by the
-@code{crash-me} test are dependent on this value. The default is
-large enough for normal operation. @xref{Benchmarks}.
-
-@item @code{timezone}
-The timezone for the server.
-
-@item @code{tmp_table_size}
-If an in-memory temporary table exceeds this size, @strong{MySQL}
-will automatically convert it to an on-disk @code{MyISAM} table.
-Increase the value of @code{tmp_table_size} if you do many advanced
-@code{GROUP BY} queries and you have lots of memory.
-
-@item @code{tmpdir}
-The directory used for temporary files and temporary tables.
-
-@item @code{version}
-The version number for the server.
-
-@item @code{wait_timeout}
-The number of seconds the server waits for activity on a connection before
-closing it. See also @code{interactive_timeout}.
-@end table
-
-The manual section that describes tuning @strong{MySQL} contains some
-information of how to tune the above variables. @xref{Server parameters}.
-
-@node SHOW LOGS, SHOW PROCESSLIST, SHOW VARIABLES, SHOW
-@subsection @code{SHOW LOGS}
-@code{SHOW LOGS} shows you status information about existing log
-files. It currently only displays information about Berkeley DB log
-files.
-
-@itemize @bullet
-@item @code{File} shows the full path to the log file
-@item @code{Type} shows the type of the log file (@code{BDB} for Berkeley
-DB log files)
-@item @code{Status} shows the status of the log file (@code{FREE} if the
-file can be removed, or @code{IN USE} if the file is needed by the transaction
-subsystem)
-@end itemize
-
-@cindex threads, display
-@cindex processes, display
-@findex threads
-@findex PROCESSLIST
-@node SHOW PROCESSLIST, SHOW GRANTS, SHOW LOGS, SHOW
-@subsection @code{SHOW PROCESSLIST}
-
-@code{SHOW PROCESSLIST} shows you which threads are running. You can
-also get this information using the @code{mysqladmin processlist}
-command. If you have the @strong{process} privilege, you can see all
-threads. Otherwise, you can see only your own threads. @xref{KILL, ,
-@code{KILL}}. If you don't use the @code{FULL} option, then only
-the first 100 characters of each query will be shown.
-
-This command is very useful if you get the 'too many connections' error
-message and want to find out what's going on. @strong{MySQL} reserves
-one extra connection for a client with the @code{Process_priv} privilege
-to ensure that you should always be able to login and check the system
-(assuming you are not giving this privilege to all your users).
-
-@cindex privileges, display
-@node SHOW GRANTS, SHOW CREATE TABLE, SHOW PROCESSLIST, SHOW
-@subsection @code{SHOW GRANTS}
-
-@code{SHOW GRANTS FOR user} lists the grant commands that must be issued to
-duplicate the grants for a user.
-
-@example
-mysql> SHOW GRANTS FOR root@@localhost;
-+---------------------------------------------------------------------+
-| Grants for root@@localhost |
-+---------------------------------------------------------------------+
-| GRANT ALL PRIVILEGES ON *.* TO 'root'@@'localhost' WITH GRANT OPTION |
-+---------------------------------------------------------------------+
-@end example
-
-@node SHOW CREATE TABLE, , SHOW GRANTS, SHOW
-@subsection @code{SHOW CREATE TABLE}
-
-Shows a @code{CREATE TABLE} statement that will create the given table:
-
-@example
-mysql> show create table t\G
-*************************** 1. row ***************************
- Table: t
-Create Table: CREATE TABLE t (
- id int(11) default NULL auto_increment,
- s char(60) default NULL,
- PRIMARY KEY (id)
-) TYPE=MyISAM
-
-@end example
-
-@code{SHOW CREATE TABLE} will quote table and column names according to
-@code{SQL_QUOTE_SHOW_CREATE} option.
-@ref{SET OPTION, , @code{SET OPTION SQL_QUOTE_SHOW_CREATE}}.
@findex EXPLAIN
@findex SELECT, optimizing
-@node EXPLAIN, DESCRIBE, SHOW, Reference
+@node EXPLAIN, DESCRIBE, USE, Reference
@section @code{EXPLAIN} Syntax (Get Information About a @code{SELECT})
@example
@@ -25511,7 +31413,7 @@ with the update log.
@end table
@findex ISOLATION LEVEL
-@node SET TRANSACTION, GRANT, SET OPTION, Reference
+@node SET TRANSACTION, CREATE INDEX, SET OPTION, Reference
@section @code{SET TRANSACTION} Syntax
@example
@@ -25534,249 +31436,13 @@ future transactions.
You can set the default isolation level for @code{mysqld} with
@code{--transaction-isolation=...}. @xref{Command-line options}.
-@cindex privileges, granting
-@cindex privileges, revoking
-@cindex global privileges
-@cindex revoking, privleges
-@cindex granting, privleges
-
-@findex GRANT
-@findex REVOKE
-@node GRANT, CREATE INDEX, SET TRANSACTION, Reference
-@section @code{GRANT} and @code{REVOKE} Syntax
-
-@example
-GRANT priv_type [(column_list)] [, priv_type [(column_list)] ...]
- ON @{tbl_name | * | *.* | db_name.*@}
- TO user_name [IDENTIFIED BY 'password']
- [, user_name [IDENTIFIED BY 'password'] ...]
- [WITH GRANT OPTION]
-
-REVOKE priv_type [(column_list)] [, priv_type [(column_list)] ...]
- ON @{tbl_name | * | *.* | db_name.*@}
- FROM user_name [, user_name ...]
-@end example
-
-@code{GRANT} is implemented in @strong{MySQL} Version 3.22.11 or later. For
-earlier @strong{MySQL} versions, the @code{GRANT} statement does nothing.
-
-The @code{GRANT} and @code{REVOKE} commands allow system administrators
-to create users and grant and revoke rights to @strong{MySQL} users at
-four privilege levels:
-
-@table @strong
-@item Global level
-Global privileges apply to all databases on a given server. These privileges
-are stored in the @code{mysql.user} table.
-
-@item Database level
-Database privileges apply to all tables in a given database. These privileges
-are stored in the @code{mysql.db} and @code{mysql.host} tables.
-
-@item Table level
-Table privileges apply to all columns in a given table. These privileges are
-stored in the @code{mysql.tables_priv} table.
-
-@item Column level
-Column privileges apply to single columns in a given table. These privileges are
-stored in the @code{mysql.columns_priv} table.
-@end table
-
-If you give a grant for a users that doesn't exists, that user is created.
-For examples of how @code{GRANT} works, see @ref{Adding users}.
-
-For the @code{GRANT} and @code{REVOKE} statements, @code{priv_type} may be
-specified as any of the following:
-
-@example
-ALL PRIVILEGES FILE RELOAD
-ALTER INDEX SELECT
-CREATE INSERT SHUTDOWN
-DELETE PROCESS UPDATE
-DROP REFERENCES USAGE
-@end example
-
-@code{ALL} is a synonym for @code{ALL PRIVILEGES}. @code{REFERENCES} is not
-yet implemented. @code{USAGE} is currently a synonym for ``no privileges.''
-It can be used when you want to create a user that has no privileges.
-
-To revoke the @strong{grant} privilege from a user, use a @code{priv_type}
-value of @code{GRANT OPTION}:
-
-@example
-REVOKE GRANT OPTION ON ... FROM ...;
-@end example
-The only @code{priv_type} values you can specify for a table are @code{SELECT},
-@code{INSERT}, @code{UPDATE}, @code{DELETE}, @code{CREATE}, @code{DROP},
-@code{GRANT}, @code{INDEX}, and @code{ALTER}.
-
-The only @code{priv_type} values you can specify for a column (that is, when
-you use a @code{column_list} clause) are @code{SELECT}, @code{INSERT}, and
-@code{UPDATE}.
-
-You can set global privileges by using @code{ON *.*} syntax. You can set
-database privileges by using @code{ON db_name.*} syntax. If you specify
-@code{ON *} and you have a current database, you will set the privileges for
-that database. (@strong{WARNING:} If you specify @code{ON *} and you
-@emph{don't} have a current database, you will affect the global privileges!)
-
-In order to accommodate granting rights to users from arbitrary hosts,
-@strong{MySQL} supports specifying the @code{user_name} value in the form
-@code{user@@host}. If you want to specify a @code{user} string
-containing special characters (such as @samp{-}), or a @code{host} string
-containing special characters or wild-card characters (such as @samp{%}), you
-can quote the user or host name (for example, @code{'test-user'@@'test-hostname'}).
-
-You can specify wild cards in the hostname. For example,
-@code{user@@"%.loc.gov"} applies to @code{user} for any host in the
-@code{loc.gov} domain, and @code{user@@"144.155.166.%"} applies to @code{user}
-for any host in the @code{144.155.166} class C subnet.
-
-The simple form @code{user} is a synonym for @code{user@@"%"}.
-@strong{NOTE:} If you allow anonymous users to connect to the @strong{MySQL}
-server (which is the default), you should also add all local users as
-@code{user@@localhost} because otherwise the anonymous user entry for the
-local host in the @code{mysql.user} table will be used when the user tries to
-log into the @strong{MySQL} server from the local machine! Anonymous users
-are defined by inserting entries with @code{User=''} into the
-@code{mysql.user} table. You can verify if this applies to you by executing
-this query:
-
-@example
-mysql> SELECT Host,User FROM mysql.user WHERE User='';
-@end example
-
-For the moment, @code{GRANT} only supports host, table, database, and
-column names up to 60 characters long. A user name can be up to 16
-characters.
-
-The privileges for a table or column are formed from the
-logical OR of the privileges at each of the four privilege
-levels. For example, if the @code{mysql.user} table specifies that a
-user has a global @strong{select} privilege, this can't be denied by an
-entry at the database, table, or column level.
-
-The privileges for a column can be calculated as follows:
-
-@example
-global privileges
-OR (database privileges AND host privileges)
-OR table privileges
-OR column privileges
-@end example
-
-In most cases, you grant rights to a user at only one of the privilege
-levels, so life isn't normally as complicated as above. The details of the
-privilege-checking procedure are presented in
-@ref{Privilege system}.
-
-If you grant privileges for a user/hostname combination that does not exist
-in the @code{mysql.user} table, an entry is added and remains there until
-deleted with a @code{DELETE} command. In other words, @code{GRANT} may
-create @code{user} table entries, but @code{REVOKE} will not remove them;
-you must do that explicitly using @code{DELETE}.
-
-@cindex passwords, setting
-In @strong{MySQL} Version 3.22.12 or later,
-if a new user is created or if you have global grant privileges, the user's
-password will be set to the password specified by the @code{IDENTIFIED BY}
-clause, if one is given. If the user already had a password, it is replaced
-by the new one.
-
-@strong{WARNING:} If you create a new user but do not specify an
-@code{IDENTIFIED BY} clause, the user has no password. This is insecure.
-
-Passwords can also be set with the @code{SET PASSWORD} command.
-@xref{SET OPTION, , @code{SET OPTION}}.
-
-If you grant privileges for a database, an entry in the @code{mysql.db}
-table is created if needed. When all privileges for the database have been
-removed with @code{REVOKE}, this entry is deleted.
-
-If a user doesn't have any privileges on a table, the table is not displayed
-when the user requests a list of tables (for example, with a @code{SHOW TABLES}
-statement).
-
-The @code{WITH GRANT OPTION} clause gives the user the ability to give
-to other users any privileges the user has at the specified privilege level.
-You should be careful to whom you give the @strong{grant} privilege, as two
-users with different privileges may be able to join privileges!
-
-You cannot grant another user a privilege you don't have yourself;
-the @strong{grant} privilege allows you to give away only those privileges
-you possess.
-
-Be aware that when you grant a user the @strong{grant} privilege at a
-particular privilege level, any privileges the user already possesses (or
-is given in the future!) at that level are also grantable by that user.
-Suppose you grant a user the @strong{insert} privilege on a database. If
-you then grant the @strong{select} privilege on the database and specify
-@code{WITH GRANT OPTION}, the user can give away not only the @strong{select}
-privilege, but also @strong{insert}. If you then grant the @strong{update}
-privilege to the user on the database, the user can give away the
-@strong{insert}, @strong{select} and @strong{update}.
-
-You should not grant @strong{alter} privileges to a normal user. If you
-do that, the user can try to subvert the privilege system by renaming
-tables!
-
-Note that if you are using table or column privileges for even one user, the
-server examines table and column privileges for all users and this will slow
-down @strong{MySQL} a bit.
-
-When @code{mysqld} starts, all privileges are read into memory.
-Database, table, and column privileges take effect at once, and
-user-level privileges take effect the next time the user connects.
-Modifications to the grant tables that you perform using @code{GRANT} or
-@code{REVOKE} are noticed by the server immediately.
-If you modify the grant tables manually (using @code{INSERT}, @code{UPDATE},
-etc.), you should execute a @code{FLUSH PRIVILEGES} statement or run
-@code{mysqladmin flush-privileges} to tell the server to reload the grant
-tables.
-@xref{Privilege changes}.
-
-@cindex ANSI SQL, differences from
-The biggest differences between the ANSI SQL and @strong{MySQL} versions of
-@code{GRANT} are:
-
-@itemize @bullet
-@item
-In @strong{MySQL} privileges are given for an username + hostname combination
-and not only for an username.
-
-@item
-ANSI SQL doesn't have global or database-level privileges, and ANSI SQL
-doesn't support all privilege types that @strong{MySQL} supports.
-@strong{MySQL} doesn't support the ANSI SQL @code{TRIGGER}, @code{EXECUTE} or
-@code{UNDER} privileges.
-
-@item
-ANSI SQL privileges are structured in a hierarchal manner. If you remove
-an user, all privileges the user has granted are revoked. In
-@strong{MySQL} the granted privileges are not automatically revoked, but
-you have to revoke these yourself if needed.
-
-@item
-If you in @strong{MySQL} have the @code{INSERT} grant on only part of the
-columns in a table, you can execute @code{INSERT} statements on the
-table; The columns for which you don't have the @code{INSERT} privilege
-will set to their default values. ANSI SQL requires you to have the
-@code{INSERT} privilege on all columns.
-
-@item
-When you drop a table in ANSI SQL, all privileges for the table are revoked.
-If you revoke a privilege in ANSI SQL, all privileges that were granted based
-on this privilege are also revoked. In @strong{MySQL}, privileges can be
-dropped only with explicit @code{REVOKE} commands or by manipulating the
-@strong{MySQL} grant tables.
-@end itemize
@cindex indexes
@cindex indexes, multi-part
@cindex multi-part index
@findex CREATE INDEX
-@node CREATE INDEX, DROP INDEX, GRANT, Reference
+@node CREATE INDEX, DROP INDEX, SET TRANSACTION, Reference
@section @code{CREATE INDEX} Syntax
@example
@@ -26050,7 +31716,7 @@ used them.
@cindex MySQL table types
@cindex @code{MyISAM} table type
@cindex types, of tables
-@node Table types, Server, Reference, Top
+@node Table types, Fulltext Search, Reference, Top
@chapter MySQL Table Types
As of @strong{MySQL} Version 3.23.6, you can choose between three basic
@@ -28465,1339 +34131,12 @@ not trivial).
@end itemize
-
-@node Server, Replication, Table types, Top
-@chapter MySQL Server Functions
-
-@cindex functions, server
-@cindex server functions
-
-@menu
-* Languages:: What languages are supported by @strong{MySQL}?
-@end menu
-
-This chapter describes the languages @strong{MySQL} supports, how sorting
-works in @strong{MySQL}, and how to add new character sets to @strong{MySQL}.
-You will also find information about maximum table sizes in this chapter.
-
-@node Languages, , Server, Server
-@section What Languages Are Supported by MySQL?
-
-@cindex error messages, languages
-@cindex messages, languages
-@cindex files, error messages
-@cindex language support
-
-@code{mysqld} can issue error messages in the following languages:
-Czech, Danish, Dutch, English (the default), Estonian, French, German, Greek,
-Hungarian, Italian, Japanese, Korean, Norwegian, Norwegian-ny, Polish,
-Portuguese, Romanian, Russian, Slovak, Spanish, and Swedish.
-
-To start @code{mysqld} with a particular language, use either the
-@code{--language=lang} or @code{-L lang} options. For example:
-
-@example
-shell> mysqld --language=swedish
-@end example
-
-or:
-
-@example
-shell> mysqld --language=/usr/local/share/swedish
-@end example
-
-Note that all language names are specified in lowercase.
-
-The language files are located (by default) in
-@file{@var{mysql_base_dir}/share/@var{LANGUAGE}/}.
-
-To update the error message file, you should edit the @file{errmsg.txt} file
-and execute the following command to generate the @file{errmsg.sys} file:
-
-@example
-shell> comp_err errmsg.txt errmsg.sys
-@end example
-
-If you upgrade to a newer version of @strong{MySQL}, remember to repeat
-your changes with the new @file{errmsg.txt} file.
-
-@menu
-* Character sets:: The character set used for data and sorting
-* Adding character set:: Adding a new character set
-* Character arrays:: The character definition arrays
-* String collating:: String collating support
-* Multi-byte characters:: Multi-byte character support
-@end menu
-
-@cindex character sets
-@cindex data, character sets
-@cindex sorting, character sets
-@node Character sets, Adding character set, Languages, Languages
-@subsection The Character Set Used for Data and Sorting
-
-By default, @strong{MySQL} uses the ISO-8859-1 (Latin1) character set
-with sorting according to Swedish/Finnish. This is the character set suitable
-in the USA and western Europe.
-
-All standard @strong{MySQL} binaries are compiled with
-@code{--with-extra-charsets=complex}. This will add code to all
-standard programs to be able to handle @code{latin1} and all multi-byte
-character sets within the binary. Other character sets will be
-loaded from a character-set definition file when needed.
-
-The character set determines what characters are allowed in names and how
-things are sorted by the @code{ORDER BY} and @code{GROUP BY} clauses of
-the @code{SELECT} statement.
-
-You can change the character set with the @code{--default-character-set}
-option when you start the server. The character sets available depend
-on the @code{--with-charset=charset} and @code{--with-extra-charset=
-list-of-charset | complex | all} options to @code{configure}, and the
-character set configuration files listed in
-@file{SHAREDIR/charsets/Index}. @xref{configure options}.
-
-If you change the character set when running @strong{MySQL} (which may
-also change the sort order), you must run myisamchk -r -q on all
-tables. Otherwise your indexes may not be ordered correctly.
-
-When a client connects to a @strong{MySQL} server, the server sends the
-default character set in use to the client. The client will switch to
-use this character set for this connection.
-
-One should use @code{mysql_real_escape_string()} when escaping strings
-for a SQL query. @code{mysql_real_escape_string()} is identical to the
-old @code{mysql_escape_string()} function, except that it takes the MYSQL
-connection handle as the first parameter.
-
-If the client is compiled with different paths than where the server is
-installed and the user who configured @strong{MySQL} didn't included all
-character sets in the @strong{MySQL} binary, one must specify for
-the client where it can find the additional character sets it will need
-if the server runs with a different character set than the client.
-
-One can specify this by putting in a @strong{MySQL} option file:
-
-@example
-[client]
-character-sets-dir=/usr/local/mysql/share/mysql/charsets
-@end example
-
-where the path points to where the dynamic @strong{MySQL} character sets
-are stored.
-
-One can force the client to use specific character set by specifying:
-
-@example
-[client]
-default-character-set=character-set-name
-@end example
-
-but normally this is never needed.
-
-@cindex character sets, adding
-@cindex adding, character sets
-@node Adding character set, Character arrays, Character sets, Languages
-@subsection Adding a New Character Set
-
-To add another character set to @strong{MySQL}, use the following procedure.
-
-Decide if the set is simple or complex. If the character set
-does not need to use special string collating routines for
-sorting and does not need multi-byte character support, it is
-simple. If it needs either of those features, it is complex.
-
-For example, @code{latin1} and @code{danish} are simple charactersets while
-@code{big5} or @code{czech} are complex character sets.
-
-In the following section, we have assumed that you name your character
-set @code{MYSET}.
-
-For a simple character set do the following:
-
-@enumerate
-@item
-Add MYSET to the end of the @file{sql/share/charsets/Index} file
-Assign an unique number to it.
-
-@item
-Create the file @file{sql/share/charsets/MYSET.conf}.
-(You can use @file{sql/share/charsets/latin1.conf} as a base for this).
-
-The syntax for the file very simple:
-
-@itemize @bullet
-@item
-Comments start with a '#' character and proceed to the end of the line.
-@item
-Words are separated by arbitrary amounts of whitespace.
-@item
-When defining the character set, every word must be a number in hexadecimal
-format
-@item
-The @code{ctype} array takes up the first 257 words. The
-@code{to_lower}, @code{to_upper} and @code{sort_order} arrays take up
-256 words each after that.
-@end itemize
-
-@xref{Character arrays}.
-
-@item
-Add the character set name to the @code{CHARSETS_AVAILABLE} and
-@code{COMPILED_CHARSETS} lists in @code{configure.in}.
-
-@item
-Reconfigure, recompile, and test.
-
-@end enumerate
-
-For a complex character set do the following:
-
-@enumerate
-@item
-Create the file @file{strings/ctype-MYSET.c} in the @strong{MySQL} source
-distribution.
-
-@item
-Add MYSET to the end of the @file{sql/share/charsets/Index} file.
-Assign an unique number to it.
-
-@item
-Look at one of the existing @file{ctype-*.c} files to see what needs to
-be defined, for example @file{strings/ctype-big5.c}. Note that the
-arrays in your file must have names like @code{ctype_MYSET},
-@code{to_lower_MYSET}, and so on. This corresponds to the arrays
-in the simple character set. @xref{Character arrays}. For a complex
-character set
-
-@item
-Near the top of the file, place a special comment like this:
-
-@example
-/*
- * This comment is parsed by configure to create ctype.c,
- * so don't change it unless you know what you are doing.
- *
- * .configure. number_MYSET=MYNUMBER
- * .configure. strxfrm_multiply_MYSET=N
- * .configure. mbmaxlen_MYSET=N
- */
-@end example
-
-The @code{configure} program uses this comment to include
-the character set into the @strong{MySQL} library automatically.
-
-The strxfrm_multiply and mbmaxlen lines will be explained in
-the following sections. Only include them if you the string
-collating functions or the multi-byte character set functions,
-respectively.
-
-@item
-You should then create some of the following functions:
-
-@itemize @bullet
-@item @code{my_strncoll_MYSET()}
-@item @code{my_strcoll_MYSET()}
-@item @code{my_strxfrm_MYSET()}
-@item @code{my_like_range_MYSET()}
-@end itemize
-
-@xref{String collating}.
-
-@item
-Add the character set name to the @code{CHARSETS_AVAILABLE} and
-@code{COMPILED_CHARSETS} lists in @code{configure.in}.
-
-@item
-Reconfigure, recompile, and test.
-@end enumerate
-
-The file @file{sql/share/charsets/README} includes some more instructions.
-
-If you want to have the character set included in the @strong{MySQL}
-distribution, mail a patch to @email{internals@@lists.mysql.com}.
-
-@node Character arrays, String collating, Adding character set, Languages
-@subsection The character definition arrays
-
-@code{to_lower[]} and @code{to_upper[]} are simple arrays that hold the
-lowercase and uppercase characters corresponding to each member of the
-character set. For example:
-
-@example
-to_lower['A'] should contain 'a'
-to_upper['a'] should contain 'A'
-@end example
-
-@code{sort_order[]} is a map indicating how characters should be ordered for
-comparison and sorting purposes. For many character sets, this is the same as
-@code{to_upper[]} (which means sorting will be case insensitive).
-@strong{MySQL} will sort characters based on the value of
-@code{sort_order[character]}. For more complicated sorting rules, see
-the discussion of string collating below. @xref{String collating}.
-
-@code{ctype[]} is an array of bit values, with one element for one character.
-(Note that @code{to_lower[]}, @code{to_upper[]}, and @code{sort_order[]}
-are indexed by character value, but @code{ctype[]} is indexed by character
-value + 1. This is an old legacy to be able to handle EOF.)
-
-You can find the following bitmask definitions in @file{m_ctype.h}:
-
-@example
-#define _U 01 /* Uppercase */
-#define _L 02 /* Lowercase */
-#define _N 04 /* Numeral (digit) */
-#define _S 010 /* Spacing character */
-#define _P 020 /* Punctuation */
-#define _C 040 /* Control character */
-#define _B 0100 /* Blank */
-#define _X 0200 /* heXadecimal digit */
-@end example
-
-The @code{ctype[]} entry for each character should be the union of the
-applicable bitmask values that describe the character. For example,
-@code{'A'} is an uppercase character (@code{_U}) as well as a
-hexadecimal digit (@code{_X}), so @code{ctype['A'+1]} should contain the
-value:
-
-@example
-_U + _X = 01 + 0200 = 0201
-@end example
-
-@cindex collating, strings
-@cindex string collating
-@node String collating, Multi-byte characters, Character arrays, Languages
-@subsection String Collating Support
-
-If the sorting rules for your language are too complex to be handled
-with the simple @code{sort_order[]} table, you need to use the string
-collating functions.
-
-Right now the best documentation on this is the character sets that are
-already implemented. Look at the big5, czech, gbk, sjis, and tis160
-character sets for examples.
-
-You must specify the @code{strxfrm_multiply_MYSET=N} value in the
-special comment at the top of the file. @code{N} should be set to
-the maximum ratio the strings may grow during @code{my_strxfrm_MYSET} (it
-must be a positive integer).
-
-@cindex characters, multi-byte
-@cindex multi-byte characters
-@node Multi-byte characters, , String collating, Languages
-@subsection Multi-byte Character Support
-
-If your want to add support for a new character set that includes
-multi-byte characters, you need to use the multi-byte character
-functions.
-
-Right now the best documentation on this is the character sets that are
-already implemented. Look at the euc_kr, gb2312, gbk, sjis and ujis
-character sets for examples. These are implemented in the
-@code{ctype-'charset'.c} files in the @file{strings} directory.
-
-You must specify the @code{mbmaxlen_MYSET=N} value in the special
-comment at the top of the source file. @code{N} should be set to the
-size in bytes of the largest character in the set.
-
-
-@cindex replication
-@cindex increasing, speed
-@cindex speed, increasing
-@cindex databases, replicating
-@node Replication, Fulltext Search, Server, Top
-@chapter Replication in MySQL
-
-@menu
-* Replication Intro:: Introduction
-* Replication Implementation:: Replication Implementation Overview
-* Replication HOWTO:: HOWTO
-* Replication Features:: Replication Features
-* Replication Options:: Replication Options in my.cnf
-* Replication SQL:: SQL Commands related to replication
-* Replication FAQ:: Frequently Asked Questions about replication
-* Replication Problems:: Troubleshooting Replication.
-@end menu
-
-This chapter describes the various replication features in @strong{MySQL}.
-It serves as a reference to the options available with replication.
-You will be introduced to replication and learn how to implement it.
-Towards the end, there are some frequently asked questions and descriptions
-of problems and how to solve them.
-
-@node Replication Intro, Replication Implementation, Replication, Replication
-@section Introduction
-
-One way replication can be used is to increase both robustness and
-speed. For robustness you can have two systems and can switch to the backup if
-you have problems with the master. The extra speed is achieved by
-sending a part of the non-updating queries to the replica server. Of
-course this only works if non-updating queries dominate, but that is the
-normal case.
-
-Starting in Version 3.23.15, @strong{MySQL} supports one-way replication
-internally. One server acts as the master, while the other acts as the
-slave. Note that one server could play the roles of master in one pair
-and slave in the other. The master server keeps a binary log of updates
-(@xref{Binary log}.) and an index file to binary logs to keep track of
-log rotation. The slave, upon connecting, informs the master where it
-left off since the last successfully propagated update, catches up on
-the updates, and then blocks and waits for the master to notify it of
-the new updates.
-
-Note that if you are replicating a database, all updates to this
-database should be done through the master!
-
-On older servers one can use the update log to do simple replication.
-@xref{Log Replication}.
-
-Another benefit of using replication is that one can get live backups of
-the system by doing a backup on a slave instead of doing it on the
-master. @xref{Backup}.
-
-@cindex master-slave setup
-@node Replication Implementation, Replication HOWTO, Replication Intro, Replication
-@section Replication Implementation Overview
-
-@strong{MySQL} replication is based on the server keeping track of all
-changes to your database (updates, deletes, etc) in the binary
-log. (@xref{Binary log}.) and the slave server(s) reading the saved
-queries from the master server's binary log so that the slave can
-execute the same queries on its copy of the data.
-
-It is @strong{very important} to realize that the binary log is simply a
-record starting from a fixed point in time (the moment you enable binary
-logging). Any slaves which you set up will need copies of all the data
-from your master as it existed the moment that you enabled binary
-logging on the master. If you start your slaves with data that doesn't
-agree with what was on the master @strong{when the binary log was
-started}, your slaves may fail.
-
-A future version (4.0) of @strong{MySQL} will remove the need to keep a
-(possibly large) snapshot of data for new slaves that you might wish to
-set up through the live backup functionality with no locking required.
-However, at this time, it is necessary to block all writes either with a
-global read lock or by shutting down the master while taking a snapshot.
-
-Once a slave is properly configured and running, it will simply connect
-to the master and wait for updates to process. If the master goes away
-or the slave loses connectivity with your master, it will keep trying to
-connect every @code{master-connect-retry} seconds until it is able to
-reconnect and resume listening for updates.
-
-Each slave keeps track of where it left off. The master server has no
-knowledge of how many slaves there are or which ones are up-to-date at
-any given time.
-
-The next section explains the master/slave setup process in more detail.
-
-@node Replication HOWTO, Replication Features, Replication Implementation, Replication
-@section HOWTO
-
-Below is a quick description of how to set up complete replication on
-your current @strong{MySQL} server. It assumes you want to replicate all
-your databases and have not configured replication before. You will need
-to shutdown your master server briefly to complete the steps outlined
-below.
-
-@enumerate
-@item
-Make sure you have a recent version of @strong{MySQL} installed on the master
-and slave(s).
-
-Use Version 3.23.29 or higher. Previous releases used a different binary
-log format and had bugs which have been fixed in newer releases. Please,
-do not report bugs until you have verified that the problem is present
-in the latest release.
-@item
-Set up special a replication user on the master with the @code{FILE}
-privilege and permission to connect from all the slaves. If the user is
-only doing replication (which is recommended), you don't need to grant any
-additional privileges.
-
-For example, to create a user named @code{repl} which can access your
-master from any host, you might use this command:
-
-@example
-GRANT FILE ON *.* TO repl@@"%" IDENTIFIED BY '<password>';
-@end example
-
-@item
-Shut down @strong{MySQL} on the master.
-
-@example
-mysqladmin -u root -p<password> shutdown
-@end example
-
-@item
-Snapshot all the data on your master server.
-
-The easiest way to do this (on Unix) is to simply use @strong{tar} to
-produce an archive of your entire data directory. The exact data
-directory location depends on your installation.
-
-@example
-tar -cvf /tmp/mysql-snapshot.tar /path/to/data-dir
-@end example
-
-Windows users can use WinZip or similar software to create an archive of
-the data directory.
-
-@item
-In @code{my.cnf} on the master add @code{log-bin} and
-@code{server-id=unique number} to the @code{[mysqld]} section and
-restart it. It is very important that the id of the slave is different from
-the id of the master. Think of @code{server-id} as something similar
-to the IP address - it uniquely identifies the server instance in the
-community of replication partners.
-
-@example
-[mysqld]
-log-bin
-server-id=1
-@end example
-
-@item
-Restart @strong{MySQL} on the master.
-
-@item
-Add the following to @code{my.cnf} on the slave(s):
-
-@example
-master-host=<hostname of the master>
-master-user=<replication user name>
-master-password=<replication user password>
-master-port=<TCP/IP port for master>
-server-id=<some unique number between 2 and 2^32-1>
-@end example
-
-replacing the values in <> with what is relevant to your system.
-
-@code{server-id} must be different for each server participating in
-replication. If you don't specify a server-id, it will be set to 1 if
-you have not defined @code{master-host}, else it will be set to 2. Note
-that in the case of @code{server-id} omission the master will refuse
-connections from all slaves, and the slave will refuse to connect to a
-master. Thus, omitting @code{server-id} is only good for backup with a
-binary log.
-
-
-@item
-Copy the snapshot data into your data directory on your slave(s). Make
-sure that the privileges on the files and directories are correct. The
-user which @strong{MySQL} runs as needs to be able to read and write to
-them, just as on the master.
-
-@item Restart the slave(s).
-
-@end enumerate
-
-After you have done the above, the slave(s) should connect to the master
-and catch up on any updates which happened since the snapshot was taken.
-
-If you have forgotten to set @code{server-id} for the slave you will get
-the following error in the error log file:
-
-@example
-Warning: one should set server_id to a non-0 value if master_host is set.
-The server will not act as a slave.
-@end example
-
-If you have forgot to do this for the master, the slaves will not be
-able to connect to the master.
-
-If a slave is not able to replicate for any reason, you will find error
-messages in the error log on the slave.
-
-Once a slave is replicating, you will find a file called
-@code{master.info} in the same directory as your error log. The
-@code{master.info} file is used by the slave to keep track of how much
-of the master's binary log is has processed. @strong{Do not} remove or
-edit the file, unless you really know what you are doing. Even in that case,
-it is preferred that you use @code{CHANGE MASTER TO} command.
-
-@cindex options, replication
-@cindex @code{my.cnf} file
-@cindex files,@code{my.cnf}
-@node Replication Features, Replication Options, Replication HOWTO, Replication
-@section Replication Features and known problems
-
-Below is an explanation of what is supported and what is not:
-
-@itemize @bullet
-@item
-Replication will be done correctly with @code{AUTO_INCREMENT},
-@code{LAST_INSERT_ID}, and @code{TIMESTAMP} values.
-@item
-@code{RAND()} in updates does not replicate properly. Use
-@code{RAND(some_non_rand_expr)} if you are replicating updates with
-@code{RAND()}. You can, for example, use @code{UNIX_TIMESTAMP()} for the
-argument to @code{RAND()}.
-@item
-You have to use the same character set (@code{--default-character-set})
-on the master and the slave. If not, you may get duplicate key errors on
-the slave, because a key that is regarded as unique on the master may
-not be that in the other character set.
-@item
-@code{LOAD DATA INFILE} will be handled properly as long as the file
-still resides on the master server at the time of update
-propagation. @code{LOAD LOCAL DATA INFILE} will be skipped.
-@item
-Update queries that use user variables are not replication-safe (yet).
-@item
-@code{FLUSH} commands are not stored in the binary log and are because
-of this not replicated to the slaves. This is not normally a problem as
-@code{FLUSH} doesn't change anything. This does however mean that if you
-update the @code{MySQL} privilege tables directly without using
-@code{GRANT} statement and you replicate the @code{MySQL} privilege
-database, you must do a @code{FLUSH PRIVILEGES} on your slaves to put
-the new privileges into effect.
-@item
-Temporary tables starting in 3.23.29 are replicated properly with the
-exception of the case when you shut down slave server ( not just slave thread),
-you have some temporary tables open, and the are used in subsequent updates.
-To deal with this problem, to shut down the slave, do @code{SLAVE STOP}, then
-check @code{Slave_open_temp_tables} variable to see if it is 0, then issue
-@code{mysqladmin shutdown}. If the number is not 0, restart the slave thread
-with @code{SLAVE START} and see
-if you have better luck next time. There will be a cleaner solution, but it
-has to wait until version 4.0.
-In earlier versions temporary tables are not being replicated properly - we
-recommend that you either upgrade, or execute @code{SET SQL_LOG_BIN=0} on
-your clients before all queries with temp tables.
-@item
-@strong{MySQL} only supports one master and many slaves. We will in 4.x
-add a voting algorithm to automatically change master if something goes
-wrong with the current master. We will also introduce 'agent' processes
-to help doing load balancing by sending select queries to different
-slaves.
-@item
-Starting in Version 3.23.26, it is safe to connect servers in a circular
-master-slave relationship with @code{log-slave-updates} enabled.
-Note, however, that many queries will not work right in this kind of
-setup unless your client code is written to take care of the potential
-problems that can happen from updates that occur in different sequence
-on different servers.
-
-This means that you can do a setup like the following:
-
-@example
-A -> B -> C -> A
-@end example
-
-This setup will only works if you only do non conflicting updates
-between the tables. In other words, if you insert data in A and C, you
-should never insert a row in A that may have a conflicting key with a
-row insert in C. You should also not update the sam rows on two servers
-if the order in which the updates are applied matters.
-
-Note that the log format has changed in Version 3.23.26 so that
-pre-3.23.26 slaves will not be able to read it.
-@item
-If the query on the slave gets an error, the slave thread will
-terminate, and a message will appear in the @code{.err} file. You should
-then connect to the slave manually, fix the cause of the error (for
-example, non-existent table), and then run @code{SLAVE START} sql
-command (available starting in Version 3.23.16). In Version 3.23.15, you
-will have to restart the server.
-@item
-If connection to the master is lost, the slave will retry immediately,
-and then in case of failure every @code{master-connect-retry} (default
-60) seconds. Because of this, it is safe to shut down the master, and
-then restart it after a while. The slave will also be able to deal with
-network connectivity outages.
-@item
-Shutting down the slave (cleanly) is also safe, as it keeps track of
-where it left off. Unclean shutdowns might produce problems, especially
-if disk cache was not synced before the system died. Your system fault
-tolerance will be greatly increased if you have a good UPS.
-@item
-If the master is listening on a non-standard port, you will also need to
-specify this with @code{master-port} parameter in @code{my.cnf} .
-@item
-In Version 3.23.15, all of the tables and databases will be
-replicated. Starting in Version 3.23.16, you can restrict replication to
-a set of databases with @code{replicate-do-db} directives in
-@code{my.cnf} or just exclude a set of databases with
-@code{replicate-ignore-db}. Note that up until Version 3.23.23, there was a bug
-that did not properly deal with @code{LOAD DATA INFILE} if you did it in
-a database that was excluded from replication.
-@item
-Starting in Version 3.23.16, @code{SET SQL_LOG_BIN = 0} will turn off
-replication (binary) logging on the master, and @code{SET SQL_LOG_BIN =
-1} will turn in back on - you must have the process privilege to do
-this.
-@item
-Starting in Version 3.23.19, you can clean up stale replication leftovers when
-something goes wrong and you want a clean start with @code{FLUSH MASTER}
-and @code{FLUSH SLAVE} commands. In Version 3.23.26 we have renamed them to
-@code{RESET MASTER} and @code{RESET SLAVE} respectively to clarify
-what they do. The old @code{FLUSH} variants still work, though, for
-compatibility.
-
-@item
-Starting in Version 3.23.21, you can use @code{LOAD TABLE FROM MASTER} for
-network backup and to set up replication initially. We have recently
-received a number of bug reports concerning it that we are investigating, so
-we recommend that you use it only in testing until we make it more stable.
-@item
-Starting in Version 3.23.23, you can change masters and adjust log position
-with @code{CHANGE MASTER TO}.
-@item
-Starting in Version 3.23.23, you tell the master that updates in certain
-databases should not be logged to the binary log with @code{binlog-ignore-db}.
-@item
-Starting in Version 3.23.26, you can use @code{replicate-rewrite-db} to tell
-the slave to apply updates from one database on the master to the one
-with a different name on the slave.
-@item
-Starting in Version 3.23.28, you can use @code{PURGE MASTER LOGS TO 'log-name'}
-to get rid of old logs while the slave is running.
-@end itemize
-
-@node Replication Options, Replication SQL, Replication Features, Replication
-@section Replication Options in my.cnf
-
-If you are using replication, we recommend you to use @strong{MySQL} Version
-3.23.30 or later. Older versions work, but they do have some bugs and are
-missing some features.
-
-On both master and slave you need to use the @code{server-id} option.
-This sets an unique replication id. You should pick a unique value in the
-range between 1 to 2^32-1 for each master and slave.
-Example: @code{server-id=3}
-
-The following table has the options you can use for the @strong{MASTER}:
-
-@multitable @columnfractions .3 .7
-
-@item @strong{Option} @tab @strong{Description}
-@item @code{log-bin=filename} @tab
-Write to a binary update log to the specified location. Note that if you
-give it a parameter with an extension (for example,
-@code{log-bin=/mysql/logs/replication.log} ) versions up to 3.23.24 will
-not work right during replication if you do @code{FLUSH LOGS} . The
-problem is fixed in Version 3.23.25. If you are using this kind of log
-name, @code{FLUSH LOGS} will be ignored on binlog. To clear the log, run
-@code{FLUSH MASTER}, and do not forget to run @code{FLUSH SLAVE} on all
-slaves. In Version 3.23.26 and in later versions you should use
-@code{RESET MASTER} and @code{RESET SLAVE}
-
-@item @code{log-bin-index=filename} @tab
-Because the user could issue the @code{FLUSH LOGS} command, we need to
-know which log is currently active and which ones have been rotated out
-and in what sequence. This information is stored in the binary log index file.
-The default is `hostname`.index. You can use this option if you want to
-be a rebel. (Example: @code{log-bin-index=db.index})
-
-@item @code{sql-bin-update-same} @tab
-If set, setting @code{SQL_LOG_BIN} to a value will automatically set
-@code{SQL_LOG_UPDATE} to the same value and vice versa.
-
-@item @code{binlog-do-db=database_name} @tab
-Tells the master it should log updates for the specified database, and
-exclude all others not explicitly mentioned.
-(Example: @code{binlog-do-db=some_database})
-
-@item @code{binlog-ignore-db=database_name} @tab
-Tells the master that updates to the given database should not be logged
-to the binary log (Example: @code{binlog-ignore-db=some_database})
-@end multitable
-
-The following table has the options you can use for the @strong{SLAVE}:
-
-@multitable @columnfractions .3 .7
-
-@item @strong{Option} @tab @strong{Description}
-@item @code{master-host=host} @tab
-Master hostname or IP address for replication. If not set, the slave
-thread will not be started.
-(Example: @code{master-host=db-master.mycompany.com})
-
-@item @code{master-user=username} @tab
-The user the slave thread will us for authentication when connecting to
-the master. The user must have @code{FILE} privilege. If the master user
-is not set, user @code{test} is assumed. (Example:
-@code{master-user=scott})
-
-@item @code{master-password=password} @tab
-The password the slave thread will authenticate with when connecting to
-the master. If not set, an empty password is assumed. (Example:
-@code{master-password=tiger})
-
-@item @code{master-port=portnumber} @tab
-The port the master is listening on. If not set, the compiled setting of
-@code{MYSQL_PORT} is assumed. If you have not tinkered with
-@code{configure} options, this should be 3306. (Example:
-@code{master-port=3306})
-
-@item @code{master-connect-retry=seconds} @tab
-The number of seconds the slave thread will sleep before retrying to
-connect to the master in case the master goes down or the connection is
-lost. Default is 60. (Example: @code{master-connect-retry=60})
-
-@item @code{master-info-file=filename} @tab
-The location of the file that remembers where we left off on the master
-during the replication process. The default is master.info in the data
-directory. Sasha: The only reason I see for ever changing the default
-is the desire to be rebelious. (Example:
-@code{master-info-file=master.info})
-
-@item @code{replicate-do-table=db_name.table_name} @tab
-Tells the slave thread to restrict replication to the specified database.
-To specify more than one table, use the directive multiple times,
-once for each table. .
-(Example: @code{replicate-do-table=some_db.some_table})
-
-@item @code{replicate-ignore-table=db_name.table_name} @tab
-Tells the slave thread to not replicate to the specified table. To
-specify more than one table to ignore, use the directive multiple
-times, once for each table.(Example:
-@code{replicate-ignore-table=db_name.some_table})
-
-@item @code{replicate-wild-do-table=db_name.table_name} @tab
-Tells the slave thread to restrict replication to the tables that match the
-specified wildcard pattern. .
-To specify more than one table, use the directive multiple times,
-once for each table. .
-(Example: @code{replicate-do-table=foo%.bar%} will replicate only updates
-to tables in all databases that start with foo and whose table names
-start with bar)
-
-@item @code{replicate-wild-ignore-table=db_name.table_name} @tab
-Tells the slave thread to not replicate to the tables that match the given
-wild card pattern. To
-specify more than one table to ignore, use the directive multiple
-times, once for each table.(Example:
-@code{replicate-ignore-table=foo%.bar%} - will not upates to tables in all databases that start with foo and whose table names
-start with bar)
-
-@item @code{replicate-ignore-db=database_name} @tab
-Tells the slave thread to not replicate to the specified database. To
-specify more than one database to ignore, use the directive multiple
-times, once for each database. This option will not work if you use cross
-database updates. If you need cross database updates to work, make sure
-you have 3.23.28 or later, and use
-@code{replicate-wild-ignore-table=db_name.%}(Example:
-@code{replicate-ignore-db=some_db})
-
-@item @code{replicate-do-db=database_name} @tab
-Tells the slave thread to restrict replication to the specified database.
-To specify more than one database, use the directive multiple times,
-once for each database. Note that this will only work if you do not use
-cross-database queries such as @code{UPDATE some_db.some_table SET
-foo='bar'} while having selected a different or no database. If you need
-cross database updates to work, make sure
-you have 3.23.28 or later, and use
-@code{replicate-wild-do-table=db_name.%}
-(Example: @code{replicate-do-db=some_db})
-
-@item @code{log-slave-updates} @tab
-Tells the slave to log the updates from the slave thread to the binary
-log. Off by default. You will need to turn it on if you plan to
-daisy-chain the slaves.
-
-@item @code{replicate-rewrite-db=from_name->to_name} @tab
-Updates to a database with a different name than the original (Example:
-@code{replicate-rewrite-db=master_db_name->slave_db_name}
-
-@item @code{skip-slave-start} @tab
-Tells the slave server not to start the slave on the startup. The user
-can start it later with @code{SLAVE START}.
-
-@item @code{slave_read_timeout=#}
-Number of seconds to wait for more data from the master before aborting
-the read.
-@end multitable
-
-@cindex SQL commands, replication
-@cindex commands, replication
-@cindex replication, commands
-@node Replication SQL, Replication FAQ, Replication Options, Replication
-@section SQL Commands Related to Replication
-
-Replication can be controlled through the SQL interface. Below is the
-summary of commands:
-
-@multitable @columnfractions .30 .70
-@item @strong{Command} @tab @strong{Description}
-
-@item @code{SLAVE START}
- @tab Starts the slave thread. (Slave)
-
-@item @code{SLAVE STOP}
- @tab Stops the slave thread. (Slave)
-
-@item @code{SET SQL_LOG_BIN=0}
- @tab Disables update logging if the user has process privilege.
- Ignored otherwise. (Master)
-
-@item @code{SET SQL_LOG_BIN=1}
- @tab Re-enables update logging if the user has process privilege.
- Ignored otherwise. (Master)
-
-@item @code{SET SQL_SLAVE_SKIP_COUNTER=n}
- @tab Skip the next @code{n} events from the master. Only valid when
-the slave thread is not running, otherwise, gives an error. Useful for
-recovering from replication glitches.
-
-@item @code{RESET MASTER}
- @tab Deletes all binary logs listed in the index file, resetting the binlog
-index file to be empty. In pre-3.23.26 versions, @code{FLUSH MASTER} (Master)
-
-@item @code{RESET SLAVE}
- @tab Makes the slave forget its replication position in the master
-logs. In pre 3.23.26 versions the command was called
-@code{FLUSH SLAVE}(Slave)
-
-@item @code{LOAD TABLE tblname FROM MASTER}
- @tab Downloads a copy of the table from master to the slave. (Slave)
-
-@item @code{CHANGE MASTER TO master_def_list}
- @tab Changes the master parameters to the values specified in
-@code{master_def_list} and restarts the slave thread. @code{master_def_list}
-is a comma-separated list of @code{master_def} where @code{master_def} is
-one of the following: @code{MASTER_HOST}, @code{MASTER_USER},
-@code{MASTER_PASSWORD}, @code{MASTER_PORT}, @code{MASTER_CONNECT_RETRY},
-@code{MASTER_LOG_FILE}, @code{MASTER_LOG_POS}. Example:
-
-@example
-
-CHANGE MASTER TO
- MASTER_HOST='master2.mycompany.com',
- MASTER_USER='replication',
- MASTER_PASSWORD='bigs3cret',
- MASTER_PORT=3306,
- MASTER_LOG_FILE='master2-bin.001',
- MASTER_LOG_POS=4;
-
-@end example
-
-You only need to specify the values that need to be changed. The values that
-you omit will stay the same with the exception of when you change the host or
-the port. In that case, the slave will assume that since you are connecting to
-a different host or a different port, the master is different. Therefore, the
-old values of log and position are not applicable anymore, and will
-automatically be reset to an empty string and 0, respectively (the start
-values). Note that if you restart the slave, it will remember its last master.
-If this is not desirable, you should delete the @file{master.info} file before
-restarting, and the slave will read its master from @code{my.cnf} or the
-command line. (Slave)
-
-@item @code{SHOW MASTER STATUS} @tab Provides status information on the binlog of the master. (Master)
-
-@item @code{SHOW SLAVE STATUS} @tab Provides status information on essential parameters of the slave thread. (Slave)
-@item @code{SHOW MASTER LOGS} @tab Only available starting in Version 3.23.28. Lists the binary logs on the master. You should use this command prior to @code{PURGE MASTER LOGS TO} to find out how far you should go.
-
-@item @code{PURGE MASTER LOGS TO 'logname'}
- @tab Available starting in Version 3.23.28. Deletes all the
-replication logs that are listed in the log
-index as being prior to the specified log, and removed them from the
-log index, so that the given log now becomes first. Example:
-
-@example
-PURGE MASTER LOGS TO 'mysql-bin.010'
-@end example
-
-This command will do nothing and fail with an error if you have an
-active slave that is currently reading one of the logs you are trying to
-delete. However, if you have a dormant slave, and happen to purge one of
-the logs it wants to read, the slave will be unable to replicate once it
-comes up. The command is safe to run while slaves are replicating - you
-do not need to stop them.
-
-You must first check all the slaves with @code{SHOW SLAVE STATUS} to
-see which log they are on, then do a listing of the logs on the
-master with @code{SHOW MASTER LOGS}, find the earliest log among all
-the slaves (if all the slaves are up to date, this will be the
-last log on the list), backup all the logs you are about to delete
-(optional) and purge up to the target log.
-
-@end multitable
-
-@node Replication FAQ, Replication Problems, Replication SQL, Replication
-@section Replication FAQ
-
-@cindex @code{Binlog_Dump}
-@strong{Q}: Why do I sometimes see more than one @code{Binlog_Dump} thread on
-the master after I have restarted the slave?
-
-@strong{A}: @code{Binlog_Dump} is a continuous process that is handled by the
-server in the following way:
-
-@itemize @bullet
-@item
-Catch up on the updates.
-@item
-Once there are no more updates left, go into @code{pthread_cond_wait()},
-from which we can be awakened either by an update or a kill.
-@item
-On wake up, check the reason. If we are not supposed to die, continue
-the @code{Binlog_dump} loop.
-@item
-If there is some fatal error, such as detecting a dead client,
-terminate the loop.
-@end itemize
-
-So if the slave thread stops on the slave, the corresponding
-@code{Binlog_Dump} thread on the master will not notice it until after
-at least one update to the master (or a kill), which is needed to wake
-it up from @code{pthread_cond_wait()}. In the meantime, the slave
-could have opened another connection, which resulted in another
-@code{Binlog_Dump} thread.
-
-The above problem should not be present in Version 3.23.26 and later
-versions. In Version 3.23.26 we added @code{server-id} to each
-replication server, and now all the old zombie threads are killed on the
-master when a new replication thread connects from the same slave
-
-@strong{Q}: How do I rotate replication logs?
-
-@strong{A}: In Version 3.23.28 you should use @code{PURGE MASTER LOGS
-TO} command after determining which logs can be deleted, and optionally
-backing them up first. In earlier versions the process is much more
-painful, and cannot be safely done without stopping all the slaves in
-the case that you plan to re-use log names. You will need to stop the
-slave threads, edit the binary log index file, delete all the old logs,
-restart the master, start slave threads, and then remove the old log files.
-
-
-@strong{Q}: How do I upgrade on a hot replication setup?
-
-@strong{A}: If you are upgrading pre-3.23.26 versions, you should just
-lock the master tables, let the slave catch up, then run @code{FLUSH
-MASTER} on the master, and @code{FLUSH SLAVE} on the slave to reset the
-logs, then restart new versions of the master and the slave. Note that
-the slave can stay down for some time - since the master is logging
-all the updates, the slave will be able to catch up once it is up and
-can connect.
-
-After 3.23.26, we have locked the replication protocol for modifications, so
-you can upgrade masters and slave on the fly to a newer 3.23 version and you
-can have different versions of @strong{MySQL} running on the slave and the
-master, as long as they are both newer than 3.23.26.
-
-@cindex replication, two-way
-@strong{Q}: What issues should I be aware of when setting up two-way
-replication?
-
-@strong{A}: @strong{MySQL} replication currently does not support any
-locking protocol between master and slave to guarantee the atomicity of
-a distributed (cross-server) update. In in other words, it is possible
-for client A to make an update to co-master 1, and in the meantime,
-before it propagates to co-master 2, client B could make an update to
-co-master 2 that will make the update of client A work differently than
-it did on co-master 1. Thus when the update of client A will make it
-to co-master 2, it will produce tables that will be different than
-what you have on co-master 1, even after all the updates from co-master
-2 have also propagated. So you should not co-chain two servers in a
-two-way replication relationship, unless you are sure that you updates
-can safely happen in any order, or unless you take care of mis-ordered
-updates somehow in the client code.
-
-
-You must also realize that two-way replication actually does not improve
-performance very much, if at all, as far as updates are concerned. Both
-servers need to do the same amount of updates each, as you would have
-one server do. The only difference is that there will be a little less
-lock contention, because the updates originating on another server will
-be serialized in one slave thread. This benefit, though, might be
-offset by network delays.
-
-@cindex performance, improving
-@cindex increasing, performance
-@strong{Q}: How can I use replication to improve performance of my system?
-
-@strong{A}: You should set up one server as the master, and direct all
-writes to it, and configure as many slaves as you have the money and
-rackspace for, distributing the reads among the master and the slaves.
-You can also start the slaves with @code{--skip-bdb},
-@code{--low-priority-updates} and @code{--delay-key-write-for-all-tables}
-to get speed improvements for the slave. In this case the slave will
-use non-transactional @code{MyISAM} tables instead of @code{BDB} tables
-to get more speed.
-
-@strong{Q}: What should I do to prepare my client code to use
-performance-enhancing replication?
-
-@strong{A}:
-If the part of your code that is responsible for database access has
-been properly abstracted/modularized, converting it to run with the
-replicated setup should be very smooth and easy - just change the
-implementation of your database access to read from some slave or the
-master, and to always write to the master. If your code does not have
-this level of abstraction,
-setting up a replicated system will give you an opportunity/motivation
-to it clean up.
- You should start by creating a wrapper library
-/module with the following functions:
-
-@itemize
-@item
-@code{safe_writer_connect()}
-@item
-@code{safe_reader_connect()}
-@item
-@code{safe_reader_query()}
-@item
-@code{safe_writer_query()}
-@end itemize
-
-@code{safe_} means that the function will take care of handling all
-the error conditions.
-
-You should then convert your client code to use the wrapper library.
-It may be a painful and scary process at first, but it will pay off in
-the long run. All applications that follow the above pattern will be
-able to take advantage of one-master/many slaves solution. The
-code will be a lot easier to maintain, and adding troubleshooting
-options will be trivial. You will just need to modify one or two
-functions, for example, to log how long each query took, or which
-query, among your many thousands, gave you an error. If you have written a lot of code already,
-you may want to automate the conversion task by using Monty's
-@code{replace} utility, which comes with the standard distribution of
-@strong{MySQL}, or just write your own Perl script. Hopefully, your
-code follows some recognizable pattern. If not, then you are probably
-better off re-writing it anyway, or at least going through and manually
-beating it into a pattern.
-
-Note that, of course, you can use different names for the
-functions. What is important is having unified interface for connecting
-for reads, connecting for writes, doing a read, and doing a write.
-
-
-@strong{Q}: When and how much can @strong{MySQL} replication improve the performance
-of my system?
-
-@strong{A}: @strong{MySQL} replication is most beneficial for a system
-with frequent reads and not so frequent writes. In theory, by using a
-one master/many slaves setup you can scale by adding more slaves until
-you either run out of network bandwidth, or your update
-load grows to the point
-that the master cannot handle it.
-
-In order to determine how many slaves you can get before the added
-benefits begin to level out, and how much you can improve performance
-of your site, you need to know your query patterns, and empirically
- (by benchmarking) determine the relationship between the throughput
-on reads (reads per second, or @code{max_reads}) and on writes
-@code{max_writes}) on a typical master and a typical slave. The
-example below will show you a rather simplified calculation of what you
-can get with replication for our imagined system.
-
-Let's say our system load consists of 10% writes and 90% reads, and we
-have determined that @code{max_reads} = 1200 - 2 * @code{max_writes},
-or in other words, our system can do 1200 reads per second with no
-writes, our average write is twice as slow as average read,
-and the relationship is
-linear. Let us suppose that our master and slave are of the same
-capacity, and we have N slaves and 1 master. Then we have for each
-server (master or slave):
-
-@code{reads = 1200 - 2 * writes} (from bencmarks)
-
-@code{reads = 9* writes / (N + 1) } (reads split, but writes go
-to all servers)
-
-@code{9*writes/(N+1) + 2 * writes = 1200}
-
-@code{writes = 1200/(2 + 9/(N+1)}
-
-So if N = 0, which means we have no replication, our system can handle
-1200/11, about 109 writes per second (which means we will have 9 times
-as many reads due to the nature of our application).
-
-If N = 1, we can get up to 184 writes per second.
-
-If N = 8, we get up to 400.
-
-If N = 17, 480 writes.
-
-Eventually as N approaches infinity (and our budget negative infinity),
-we can get very close to 600 writes per second, increasing system
-throughput about 5.5 times. However, with only 8 servers, we increased
-it almost 4 times already.
-
-Note that our computations assumed infinite network bandwidth, and
-neglected several other factors that could turn out to be significant on
-your system. In many cases, you may not be able to make a computation
-similar to the one above that will accurately predict what will happen
-on your system if you add N replication slaves. However, answering the
-following questions should help you decided whether and how much, if at
-all, the replication will improve the performance of your system:
-
-@itemize @bullet
-@item
-What is the read/write ratio on your system?
-@item
-How much more write load can one server handle if you reduce the reads?
-@item
-How many slaves do you have bandwidth for on your network?
-@end itemize
-
-@strong{Q}: How can I use replication to provide redundancy/high
-availability?
-
-@strong{A}: With the currently available features, you would have to
-set up a master and a slave (or several slaves), and write a script
-that will monitor the
-master to see if it is up, and instruct your applications and
-the slaves of the master change in case of failure. Some suggestions:
-
-@itemize @bullet
-@item
-To tell a slave to change the master use the @code{CHANGE MASTER TO} command.
-@item
-A good way to keep your applications informed where the master is by
-having a dynamic DNS entry for the master. With @strong{bind} you can
-use @code{nsupdate} to dynamically update your DNS.
-@item
-You should run your slaves with the @code{log-bin} option and without
-@code{log-slave-updates}. This way the slave will be ready to become a
-master as soon as you issue @code{STOP SLAVE}; @code{RESET MASTER}, and
-@code{CHANGE MASTER TO} on the other slaves. It will also help you catch
-spurious updates that may happen because of misconfiguration of the
-slave (ideally, you want to configure access rights so that no client
-can update the slave, except for the slave thread) combined with the
-bugs in your client programs (they should never update the slave
-directly).
-
-@end itemize
-
-We are currently working on integrating an automatic master election
-system into @strong{MySQL}, but until it is ready, you will have to
-create your own monitoring tools.
-
-@node Replication Problems, , Replication FAQ, Replication
-@section Troubleshooting Replication
-
-If you have followed the instructions, and your replication setup is not
-working, first eliminate the user error factor by checking the following:
-
-@itemize @bullet
-@item
-Is the master logging to the binary log? Check with @code{SHOW MASTER STATUS}.
-If it is, @code{Position} will be non-zero. If not, verify that you have
-given the master @code{log-bin} option and have set @code{server-id}.
-@item
-Is the slave running? Check with @code{SHOW SLAVE STATUS}. The answer is found
-in @code{Slave_running} column. If not, verify slave options and check the
-error log for messages.
-@item
-If the slave is running, did it establish connection with the master? Do
-@code{SHOW PROCESSLIST}, find the thread with @code{system user} value in
-@code{User} column and @code{none} in the @code{Host} column, and check the
-@code{State} column. If it says @code{connecting to master}, verify the
-privileges for the replication user on the master, master host name, your
-DNS setup, whether the master is actually running, whether it is reachable
-from the slave, and if all that seems ok, read the error logs.
-@item
-If the slave was running, but then stopped, look at SHOW SLAVE STATUS
-output and check the error logs. It usually
-happens when some query that succeeded on the master fails on the slave. This
-should never happen if you have taken a proper snapshot of the master, and
-never modify the data on the slave outside of the slave thread. If it does,
-it is a bug, read below on how to report it.
-@item
-If a query on that succeeded on the master refuses to run on the slave, and
-a full database resync ( the proper thing to do ) does not seem feasible,
-try the following:
-@itemize bullet
-@item
-First see if there is some stray record in the way. Understand how it got
-there, then delete it and run @code{SLAVE START}
-@item
-If the above does not work or does not apply, try to understand if it would
-be safe to make the update manually ( if needed) and then ignore the next
-query from the master.
-@item
-If you have decided you can skip the next query, do
-@code{SET SQL_SLAVE_SKIP_COUNTER=1; SLAVE START;} to skip a query that
-does not use auto_increment, or last_insert_id or
-@code{SET SQL_SLAVE_SKIP_COUNTER=2; SLAVE START;} otherwise. The reason
-auto_increment/last_insert_id queries are different is that they take
-two events in the binary log of the master.
-
-@item
-If you are sure the slave started out perfectly in sync with the master,
-and no one has updated the tables involved outside of slave thread,
-report the bug, so
-you will not have to do the above tricks again.
-@end itemize
-@item
-Make sure you are not running into an old bug by upgrading to the most recent
-version.
-@item
-If all else fails, read the error logs. If they are big,
-@code{grep -i slave /path/to/your-log.err} on the slave. There is no
-generic pattern to search for on the master, as the only errors it logs
-are general system errors - if it can, it will send the error to the slave
-when things go wrong.
-@end itemize
-
-When you have determined that there is no user error involved, and replication
-still either does not work at all or is unstable, it is time to start working
-on a bug report. We need to get as much info as possible from you to be able
-to track down the bug. Please do spend some time and effort preparing a good
-bug report. Ideally, we would like to have a test case in the format found in
-@code{mysql-test/t/rpl*} directory of the source tree. If you submit a test
-case like that, you can expect a patch within a day or two in most cases,
-although, of course, you mileage may vary depending on a number of factors.
-
-Second best option is a just program with easily configurable connection
-arguments for the master and the slave that will demonstrate the problem on our
-systems. You can write one in Perl or in C, depending on which language you
-know better.
-
-If you have one of the above ways to demonstrate the bug, use
-@code{mysqlbug} to prepare a bug report and send it to
-@email{bugs@@lists.mysql.com}. If you have a phantom - a problem that
-does occur but you cannot duplicate "at will":
-
-@itemize @bullet
-@item
-Verify that there is no user error involved. For example, if you update the
-slave outside of the slave thread, the data will be out of sync, and you can
-have unique key violations on updates, in which case the slave thread will
-stop and wait for you to clean up the tables manually to bring them in sync.
-@item
-Run slave with @code{log-slave-updates} and @code{log-bin} - this will keep
-a log of all updates on the slave.
-@item
-Save all evidence before resetting the replication. If we have no or only
-sketchy information, it would take us a while to track down the problem. The
-evidence you should collect is:
-@itemize @bullet
-@item
-All binary logs on the master
-@item
-All binary log on the slave
-@item
-The output of @code{SHOW MASTER STATUS} on the master at the time
-you have discovered the problem
-@item
-The output of @code{SHOW SLAVE STATUS} on the master at the time
-you have discovered the problem
-@item
-Error logs on the master and on the slave
-@end itemize
-@item
-Use @code{mysqlbinlog} to examine the binary logs. The following should
-be helpful
-to find the trouble query, for example:
-@example
-mysqlbinlog -j pos_from_slave_status /path/to/log_from_slave_status | head
-@end example
-@end itemize
-
-Once you have collected the evidence on the phantom problem, try hard to
-isolate it into a separate test case first. Then report the problem to
-@email{bugs@@lists.mysql.com} with as much info as possible.
+@node Fulltext Search, Performance, Table types, Top
+@chapter MySQL Full-text Search
@cindex searching, full-text
@cindex full-text search
@cindex FULLTEXT
-@node Fulltext Search, Performance, Replication, Top
-@chapter MySQL Full-text Search
Since Version 3.23.23, @strong{MySQL} has support for full-text indexing
and searching. Full-text indexes in @strong{MySQL} are an index of type
@@ -32157,7 +36496,7 @@ going. Hopefully this will be better handled in future Linux Kernels.
@cindex benchmark suite
@cindex crash-me program
-@node MySQL Benchmarks, Tools, Performance, Top
+@node MySQL Benchmarks, Maintenance, Performance, Top
@chapter The MySQL Benchmark Suite
This should contain a technical description of the @strong{MySQL}
@@ -32243,1828 +36582,9 @@ How big a @code{VARCHAR} column can be
We can find the result from crash-me on a lot of different databases at
@uref{http://www.mysql.com/information/crash-me.php}.
-@cindex utilities
-@node Tools, Maintenance, MySQL Benchmarks, Top
-@chapter MySQL Utilites
-
-@menu
-* Programs:: What do the executables do?
-* mysqld-max:: mysqld-max, An extended mysqld server
-* safe_mysqld:: safe_mysqld, the wrapper around mysqld
-* mysqld_multi:: Program for managing multiple @strong{MySQL} servers
-* mysql:: The command line tool
-* mysqladmin:: Administering a @strong{MySQL} server
-* mysqldump:: Dumping the structure and data from @strong{MySQL} databases and tables
-* mysqlhotcopy:: Copying @strong{MySQL} Databases and Tables
-* mysqlimport:: Importing data from text files
-* perror:: Displaying error messages
-* mysqlshow:: Showing databases, tables and columns
-* myisampack:: The @strong{MySQL} compressed read-only table generator
-@end menu
-
-In this chapter you will learn about the @strong{MySQL} Utilities that
-come in a given distribution. You will learn what each of them does, how
-to use it, and what you should use it for.
-
-@cindex environment variables
-@cindex programs, list of
-@node Programs, mysqld-max, Tools, Tools
-@section Overview of the Different MySQL Programs
-
-All @strong{MySQL} clients that communicate with the server using the
-@code{mysqlclient} library use the following environment variables:
-
-@tindex MYSQL_UNIX_PORT environment variable
-@tindex Environment variable, MYSQL_UNIX_PORT
-@tindex MYSQL_TCP_PORT environment variable
-@tindex Environment variable, MYSQL_TCP_PORT
-@tindex MYSQL_PWD environment variable
-@tindex Environment variable, MYSQL_PWD
-@tindex MYSQL_DEBUG environment variable
-@tindex Environment variable, MYSQL_DEBUG
-@multitable @columnfractions .25 .75
-@item @strong{Name} @tab @strong{Description}
-@item @code{MYSQL_UNIX_PORT} @tab The default socket; used for connections to @code{localhost}
-@item @code{MYSQL_TCP_PORT} @tab The default TCP/IP port
-@item @code{MYSQL_PWD} @tab The default password
-@item @code{MYSQL_DEBUG} @tab Debug-trace options when debugging
-@item @code{TMPDIR} @tab The directory where temporary tables/files are created
-@end multitable
-
-Use of @code{MYSQL_PWD} is insecure.
-@xref{Connecting}.
-
-@tindex MYSQL_HISTFILE environment variable
-@tindex Environment variable, MYSQL_HISTFILE
-@tindex HOME environment variable
-@tindex Environment variable, HOME
-@cindex history file
-@cindex command line history
-@tindex .mysql_history file
-The @file{mysql} client uses the file named in the @code{MYSQL_HISTFILE}
-environment variable to save the command-line history. The default value for
-the history file is @file{$HOME/.mysql_history}, where @code{$HOME} is the
-value of the @code{HOME} environment variable. @xref{Environment variables}.
-
-All @strong{MySQL} programs take many different options. However, every
-@strong{MySQL} program provides a @code{--help} option that you can use
-to get a full description of the program's different options. For example, try
-@code{mysql --help}.
-
-You can override default options for all standard client programs with an
-option file. @ref{Option files}.
-
-The list below briefly describes the @strong{MySQL} programs:
-
-@table @code
-
-@cindex @code{myisamchk}
-@item myisamchk
-Utility to describe, check, optimize, and repair @strong{MySQL} tables.
-Because @code{myisamchk} has many functions, it is described in its own
-chapter. @xref{Maintenance}.
-
-@cindex @code{make_binary_distribution}
-@item make_binary_distribution
-Makes a binary release of a compiled @strong{MySQL}. This could be sent
-by FTP to @file{/pub/mysql/Incoming} on @code{support.mysql.com} for the
-convenience of other @strong{MySQL} users.
-
-@cindex @code{msql2mysql}
-@item msql2mysql
-A shell script that converts @code{mSQL} programs to @strong{MySQL}. It doesn't
-handle all cases, but it gives a good start when converting.
-
-@cindex @code{mysqlaccess}
-@item mysqlaccess
-A script that checks the access privileges for a host, user, and database
-combination.
-
-@cindex @code{mysqladmin}
-@item mysqladmin
-Utility for performing administrative operations, such as creating or
-dropping databases, reloading the grant tables, flushing tables to disk, and
-reopening log files. @code{mysqladmin} can also be used to retrieve version,
-process, and status information from the server.
-@xref{mysqladmin, , @code{mysqladmin}}.
-
-@cindex @code{mysqlbug}
-@item mysqlbug
-The @strong{MySQL} bug report script. This script should always be used when
-filing a bug report to the @strong{MySQL} list.
-
-@cindex @code{mysqld}
-@item mysqld
-The SQL daemon. This should always be running.
-
-@cindex @code{mysqldump}
-@item mysqldump
-Dumps a @strong{MySQL} database into a file as SQL statements or
-as tab-separated text files. Enhanced freeware originally by Igor Romanenko.
-@xref{mysqldump, , @code{mysqldump}}.
-
-@cindex @code{mysqlimport}
-@item mysqlimport
-Imports text files into their respective tables using @code{LOAD DATA
-INFILE}. @xref{mysqlimport, , @code{mysqlimport}}.
-
-@cindex @code{mysqlshow}
-@item mysqlshow
-Displays information about databases, tables, columns, and indexes.
-
-@cindex @code{mysql_install_db}
-@item mysql_install_db
-Creates the @strong{MySQL} grant tables with default privileges. This is
-usually executed only once, when first installing @strong{MySQL}
-on a system.
-
-@cindex @code{replace}
-@item replace
-A utility program that is used by @code{msql2mysql}, but that has more
-general applicability as well. @code{replace} changes strings in place in
-files or on the standard input. Uses a finite state machine to match longer
-strings first. Can be used to swap strings. For example, this command
-swaps @code{a} and @code{b} in the given files:
-
-@example
-shell> replace a b b a -- file1 file2 ...
-@end example
-@end table
-
-@cindex @code{mysqld-max}
-@node mysqld-max, safe_mysqld, Programs, Tools
-@section mysqld-max, An extended mysqld server
-
-@code{mysqld-max} is the MySQL server (@code{mysqld}) configured with
-the following configure options:
-
-@multitable @columnfractions .3 .7
-@item @strong{Option} @tab @strong{Comment}
-@item --with-server-suffix=-max @tab Add a suffix to the @code{mysqld} version string.
-@item --with-bdb @tab Support for Berkeley DB (BDB) tables
-@item --with-innodb @tab Support for InnoDB tables.
-@item CFLAGS=-DUSE_SYMDIR @tab Symbolic links support for Windows.
-@end multitable
-
-You can find the @strong{MySQL}-max binaries at
-@uref{http://www.mysql.com/downloads/mysql-max-3.23.html}.
-
-The Windows @strong{MySQL} 3.23 binary distribution includes both the
-standard @strong{mysqld.exe} binary and the @code{mysqld-max.exe} binary.
-@uref{http://www.mysql.com/downloads/mysql-3.23.html}.
-@xref{Windows installation}.
-
-Note that as Berkeley DB and InnoDB are not available for all platforms,
-some of the @code{Max} binaries may not have support for both of these.
-You can check which table types are supported by doing the following
-query:
-
-@example
-mysql> show variables like "have_%";
-+---------------+-------+
-| Variable_name | Value |
-+---------------+-------+
-| have_bdb | YES |
-| have_innodb | NO |
-| have_isam | YES |
-| have_raid | YES |
-| have_ssl | NO |
-+---------------+-------+
-@end example
-
-The meaning of the values are:
-
-@multitable @columnfractions .3 .7
-@item @strong{Value} @tab @strong{Meaning}.
-@item YES @tab The option is activated and usable.
-@item NO @tab @strong{MySQL} is not compiled with support for this option.
-@item DISABLED @tab The xxxx option is disabled because one started @code{mysqld} with @code{--skip-xxxx} or because one didn't start @code{mysqld} with all needed options to enable the option. In this case the @code{hostname.err} file should contain a reason for why the option is disabled.
-@end multitable
-
-@strong{NOTE}: To be able to create InnoDB tables you @strong{MUST} edit
-your startup options to include at least the @code{innodb_data_file_path}
-option. @xref{InnoDB start}.
-
-To get better performance for BDB tables, you should add some configuration
-options for these too. @xref{BDB start}.
-
-@code{safe_mysqld} will automatically try to start any @code{mysqld} binary
-with the @code{-max} prefix. This makes it very easy to test out a
-another @code{mysqld} binary in an existing installation. Just
-run @code{configure} with the options you want and then install the
-new @code{mysqld} binary as @code{mysqld-max} in the same directory
-where your old @code{mysqld} binary is. @xref{safe_mysqld, , @code{safe_mysqld}}.
-
-The @code{mysqld-max} RPM uses the above mentioned @code{safe_mysqld}
-feature. It just installs the @code{mysqld-max} executable and
-@code{safe_mysqld} will automatically use this executable when
-@code{safe_mysqld} is restarted.
-
-The following table shows which table types our standard @strong{MySQL-Max}
-binaries includes:
-
-@multitable @columnfractions .4 .3 .3
-@item @strong{System} @tab @strong{BDB} @tab @strong{InnoDB}
-@item AIX 4.3 @tab N @tab Y
-@item HP-UX 11.0 @tab N @tab Y
-@item Linux-Alpha @tab N @tab Y
-@item Linux-Intel @tab Y @tab Y
-@item Linux-Ia64 @tab N @tab Y
-@item Solaris-intel @tab N @tab Y
-@item Solaris-sparc @tab Y @tab Y
-@item SCO OSR5 @tab Y @tab Y
-@item UnixWare @tab Y @tab Y
-@item Windows/NT @tab Y @tab Y
-@end multitable
-
-@cindex tools, safe_mysqld
-@cindex scripts
-@cindex @code{safe_mysqld}
-@node safe_mysqld, mysqld_multi, mysqld-max, Tools
-@section safe_mysqld, the wrapper around mysqld
-
-@code{safe_mysqld} is the recommended way to start a @code{mysqld}
-daemon on Unix. @code{safe_mysqld} adds some safety features such as
-restarting the server when an error occurs and logging run-time
-information to a log file.
-
-If you don't use @code{--mysqld=#} or @code{--mysqld-version=#}
-@code{safe_mysqld} will use an executable named @code{mysqld-max} if it
-exists. If not, @code{safe_mysqld} will start @code{mysqld}.
-This makes it very easy to test to use @code{mysqld-max} instead of
-@code{mysqld}; Just copy @code{mysqld-max} to where you have
-@code{mysqld} and it will be used.
-
-Normally one should never edit the @code{safe_mysqld} script, but
-instead put the options to @code{safe_mysqld} in the
-@code{[safe_mysqld]} section in the @code{my.cnf}
-file. @code{safe_mysqld} will read all options from the @code{[mysqld]},
-@code{[server]} and @code{[safe_mysqld]} sections from the option files.
-@xref{Option files}.
-
-Note that all options on the command line to @code{safe_mysqld} are passed
-to @code{mysqld}. If you wants to use any options in @code{safe_mysqld} that
-@code{mysqld} doesn't support, you must specify these in the option file.
-
-Most of the options to @code{safe_mysqld} are the same as the options to
-@code{mysqld}. @xref{Command-line options}.
-
-@code{safe_mysqld} supports the following options:
-
-@table @code
-@item --basedir=path
-@item --core-file-size=#
-Size of the core file @code{mysqld} should be able to create. Passed to @code{ulimit -c}.
-@item --datadir=path
-@item --defaults-extra-file=path
-@item --defaults-file=path
-@item --err-log=path
-@item --ledir=path
-Path to @code{mysqld}
-@item --log=path
-@item --mysqld=mysqld-version
-Name of the @code{mysqld} version in the @code{ledir} directory you want to start.
-@item --mysqld-version=version
-Similar to @code{--mysqld=} but here you only give the suffix for @code{mysqld}.
-For example if you use @code{--mysqld-version=max}, @code{safe_mysqld} will
-start the @code{ledir/mysqld-max} version. If the argument to
-@code{--mysqld-version} is empty, @code{ledir/mysqld} will be used.
-@item --no-defaults
-@item --open-files-limit=#
-Number of files @code{mysqld} should be able to open. Passed to @code{ulimit -n}. Note that you need to start @code{safe_mysqld} as root for this to work properly!
-@item --pid-file=path
-@item --port=#
-@item --socket=path
-@item --timezone=#
-Set the timezone (the @code{TZ}) variable to the value of this parameter.
-@item --user=#
-@end table
-
-The @code{safe_mysqld} script is written so that it normally is able to start
-a server that was installed from either a source or a binary version of
-@strong{MySQL}, even if these install the server in slightly different
-locations. @code{safe_mysqld} expects one of these conditions to be true:
-
-@itemize @bullet
-@item
-The server and databases can be found relative to the directory from which
-@code{safe_mysqld} is invoked. @code{safe_mysqld} looks under its working
-directory for @file{bin} and @file{data} directories (for binary
-distributions) or for @file{libexec} and @file{var} directories (for source
-distributions). This condition should be met if you execute
-@code{safe_mysqld} from your @strong{MySQL} installation directory (for
-example, @file{/usr/local/mysql} for a binary distribution).
-
-@item
-If the server and databases cannot be found relative to the working directory,
-@code{safe_mysqld} attempts to locate them by absolute pathnames. Typical
-locations are @file{/usr/local/libexec} and @file{/usr/local/var}.
-The actual locations are determined when the distribution was built from which
-@code{safe_mysqld} comes. They should be correct if
-@strong{MySQL} was installed in a standard location.
-@end itemize
-
-Because @code{safe_mysqld} will try to find the server and databases relative
-to its own working directory, you can install a binary distribution of
-@strong{MySQL} anywhere, as long as you start @code{safe_mysqld} from the
-@strong{MySQL} installation directory:
-
-@example
-shell> cd mysql_installation_directory
-shell> bin/safe_mysqld &
-@end example
-
-If @code{safe_mysqld} fails, even when invoked from the @strong{MySQL}
-installation directory, you can modify it to use the path to @code{mysqld}
-and the pathname options that are correct for your system. Note that if you
-upgrade @strong{MySQL} in the future, your modified version of
-@code{safe_mysqld} will be overwritten, so you should make a copy of your
-edited version that you can reinstall.
-
-@cindex tools, mysqld_multi
-@cindex scripts
-@cindex multi mysqld
-@cindex @code{mysqld_multi}
-@node mysqld_multi, mysql, safe_mysqld, Tools
-@section mysqld_multi, program for managing multiple @strong{MySQL} servers
-
-@code{mysqld_multi} is meant for managing several @code{mysqld}
-processes running in different UNIX sockets and TCP/IP ports.
-
-The program will search for group(s) named [mysqld#] from my.cnf (or the
-given --config-file=...), where # can be any positive number starting
-from 1. These groups should be the same as the usual @code{[mysqld]}
-group (e.g. options to mysqld, see @strong{MySQL} manual for detailed
-information about this group), but with those port, socket etc. options
-that are wanted for each separate @code{mysqld} processes. The number in
-the group name has another function; it can be used for starting,
-stopping, or reporting some specific @code{mysqld} servers with this
-program. See the usage and options below for more information.
-
-@example
-Usage: mysqld_multi [OPTIONS] @{start|stop|report@} [GNR,GNR,GNR...]
-or mysqld_multi [OPTIONS] @{start|stop|report@} [GNR-GNR,GNR,GNR-GNR,...]
-@end example
-
-The GNR above means the group number. You can start, stop or report
-any GNR, or several of them at the same time. (See --example) The GNRs
-list can be comma separated, or a dash combined, of which the latter
-means that all the GNRs between GNR1-GNR2 will be affected. Without
-GNR argument all the found groups will be either started, stopped, or
-reported. Note that you must not have any white spaces in the GNR
-list. Anything after a white space is ignored.
-
-@code{mysqld_multi} supports the following options:
-
-@table @code
-@cindex config-file option
-@item --config-file=...
-Alternative config file. NOTE: This will not affect this program's own
-options (group @code{[mysqld_multi]}), but only groups
-[mysqld#]. Without this option everything will be searched from the
-ordinary my.cnf file.
-@cindex example option
-@item --example
-Give an example of a config file.
-@cindex help option
-@item --help
-Print this help and exit.
-@cindex log option
-@item --log=...
-Log file. Full path to and the name for the log file. NOTE: If the file
-exists, everything will be appended.
-@cindex mysqladmin option
-@item --mysqladmin=...
-@code{mysqladmin} binary to be used for a server shutdown.
-@cindex mysqld option
-@item --mysqld=...
-@code{mysqld} binary to be used. Note that you can give
-@code{safe_mysqld} to this option also. The options are passed to
-@code{mysqld}. Just make sure you have @code{mysqld} in your environment
-variable @code{PATH} or fix @code{safe_mysqld}.
-@cindex no-log option
-@item --no-log
-Print to stdout instead of the log file. By default the log file is
-turned on.
-@cindex password option
-@item --password=...
-Password for user for @code{mysqladmin}.
-@cindex tcp-ip option
-@item --tcp-ip
-Connect to the @strong{MySQL} server(s) via the TCP/IP port instead of
-the UNIX socket. This affects stopping and reporting. If a socket file
-is missing, the server may still be running, but can be accessed only
-via the TCP/IP port. By default connecting is done via the UNIX socket.
-@cindex user option
-@item --user=...
-@strong{MySQL} user for @code{mysqladmin}.
-@cindex version option
-@item --version
-Print the version number and exit.
-@end table
-
-Some notes about @code{mysqld_multi}:
-
-@itemize @bullet
-@item
-Make sure that the @strong{MySQL} user, who is stopping the
-@code{mysqld} services (e.g using the @code{mysqladmin}) have the same
-password and username for all the data directories accessed (to the
-'mysql' database) And make sure that the user has the 'Shutdown_priv'
-privilege! If you have many data- directories and many different 'mysql'
-databases with different passwords for the @strong{MySQL} 'root' user,
-you may want to create a common 'multi_admin' user for each using the
-same password (see below). Example how to do it:
-@example
-shell> mysql -u root -S /tmp/mysql.sock -proot_password -e
-"GRANT SHUTDOWN ON *.* TO multi_admin@@localhost IDENTIFIED BY 'multipass'"
-@xref{Privileges}.
-@end example
-You will have to do the above for each @code{mysqld} running in each
-data directory, that you have (just change the socket, -S=...)
-@item
-@code{pid-file} is very important, if you are using @code{safe_mysqld}
-to start @code{mysqld} (e.g. --mysqld=safe_mysqld) Every @code{mysqld}
-should have its own @code{pid-file}. The advantage using
-@code{safe_mysqld} instead of @code{mysqld} directly here is, that
-@code{safe_mysqld} 'guards' every @code{mysqld} process and will restart
-it, if a @code{mysqld} process fails due to signal kill -9, or
-similar. (Like segmentation fault, which @strong{MySQL} should never do,
-of course ;) Please note that @code{safe_mysqld} script may require that
-you start it from a certain place. This means that you may have to CD to
-a certain directory, before you start the @code{mysqld_multi}. If
-you have problems starting, please see the @code{safe_mysqld}
-script. Check especially the lines:
-@example
---------------------------------------------------------------------------
-MY_PWD=`pwd` Check if we are starting this relative (for the binary
-release) if test -d /data/mysql -a -f ./share/mysql/english/errmsg.sys
--a -x ./bin/mysqld
---------------------------------------------------------------------------
-@xref{safe_mysqld, , @code{safe_mysqld}}.
-@end example
-The above test should be successful, or you may encounter problems.
-@item
-Beware of the dangers starting multiple @code{mysqlds} in the same data
-directory. Use separate data directories, unless you @strong{KNOW} what
-you are doing!
-@item
-The socket file and the TCP/IP port must be different for every @code{mysqld}.
-@item
-The first and fifth @code{mysqld} group were intentionally left out from
-the example. You may have 'gaps' in the config file. This gives you
-more flexibility. The order in which the @code{mysqlds} are started or
-stopped depends on the order in which they appear in the config file.
-@item
-When you want to refer to a certain group using GNR with this program,
-just use the number in the end of the group name ( [mysqld# <== ).
-@item
-You may want to use option '--user' for @code{mysqld}, but in order to
-do this you need to be root when you start the @code{mysqld_multi}
-script. Having the option in the config file doesn't matter; you will
-just get a warning, if you are not the superuser and the @code{mysqlds}
-are started under @strong{YOUR} UNIX account. @strong{IMPORTANT}: Make
-sure that the @code{pid-file} and the data directory are
-read+write(+execute for the latter one) accessible for @strong{THAT}
-UNIX user, who the specific @code{mysqld} process is started
-as. @strong{DON'T} use the UNIX root account for this, unless you
-@strong{KNOW} what you are doing!
-@item
-@strong{MOST IMPORTANT}: Make sure that you understand the meanings of
-the options that are passed to the @code{mysqlds} and why @strong{WOULD
-YOU WANT} to have separate @code{mysqld} processes. Starting multiple
-@code{mysqlds} in one data directory @strong{WILL NOT} give you extra
-performance in a threaded system!
-@end itemize
-
-@xref{Multiple servers}.
-
-This is an example of the config file on behalf of @code{mysqld_multi}.
-
-@example
-# This file should probably be in your home dir (~/.my.cnf) or /etc/my.cnf
-# Version 2.1 by Jani Tolonen
-
-[mysqld_multi]
-mysqld = /usr/local/bin/safe_mysqld
-mysqladmin = /usr/local/bin/mysqladmin
-user = multi_admin
-password = multipass
-
-[mysqld2]
-socket = /tmp/mysql.sock2
-port = 3307
-pid-file = /usr/local/mysql/var2/hostname.pid2
-datadir = /usr/local/mysql/var2
-language = /usr/local/share/mysql/english
-user = john
-
-[mysqld3]
-socket = /tmp/mysql.sock3
-port = 3308
-pid-file = /usr/local/mysql/var3/hostname.pid3
-datadir = /usr/local/mysql/var3
-language = /usr/local/share/mysql/swedish
-user = monty
-
-[mysqld4]
-socket = /tmp/mysql.sock4
-port = 3309
-pid-file = /usr/local/mysql/var4/hostname.pid4
-datadir = /usr/local/mysql/var4
-language = /usr/local/share/mysql/estonia
-user = tonu
-
-[mysqld6]
-socket = /tmp/mysql.sock6
-port = 3311
-pid-file = /usr/local/mysql/var6/hostname.pid6
-datadir = /usr/local/mysql/var6
-language = /usr/local/share/mysql/japanese
-user = jani
-@end example
-
-@xref{Option files}.
-
-@cindex command line tool
-@cindex tools, command line
-@cindex scripts
-@cindex @code{mysql}
-@node mysql, mysqladmin, mysqld_multi, Tools
-@section The Command-line Tool
-
-@code{mysql} is a simple SQL shell (with GNU @code{readline} capabilities).
-It supports interactive and non-interactive use. When used interactively,
-query results are presented in an ASCII-table format. When used
-non-interactively (for example, as a filter), the result is presented in
-tab-separated format. (The output format can be changed using command-line
-options.) You can run scripts simply like this:
-
-@example
-shell> mysql database < script.sql > output.tab
-@end example
-
-If you have problems due to insufficient memory in the client, use the
-@code{--quick} option! This forces @code{mysql} to use
-@code{mysql_use_result()} rather than @code{mysql_store_result()} to
-retrieve the result set.
-
-Using @code{mysql} is very easy. Just start it as follows:
-@code{mysql database} or @code{mysql --user=user_name --password=your_password database}. Type a SQL statement, end it with @samp{;}, @samp{\g}, or @samp{\G}
-and press RETURN/ENTER.
-
-@cindex command line options
-@cindex options, command line
-@cindex startup parameters
-@code{mysql} supports the following options:
-
-@table @code
-@cindex help option
-@item -?, --help
-Display this help and exit.
-@cindex automatic rehash option
-@item -A, --no-auto-rehash
-No automatic rehashing. One has to use 'rehash' to get table and field
-completion. This gives a quicker start of mysql.
-@cindex batch option
-@item -B, --batch
-Print results with a tab as separator, each row on a new line. Doesn't use
-history file.
-@cindex character sets option
-@item --character-sets-dir=...
-Directory where character sets are located.
-@cindex compress option.
-@item -C, --compress
-Use compression in server/client protocol.
-@cindex debug option
-@item -#, --debug[=...]
-Debug log. Default is 'd:t:o,/tmp/mysql.trace'.
-@cindex database option
-@item -D, --database=...
-Database to use. This is mainly useful in the @code{my.cnf} file.
-@cindex default character set option
-@item --default-character-set=...
-Set the default character set.
-@cindex execute option
-@item -e, --execute=...
-Execute command and quit. (Output like with --batch)
-@cindex vertical option
-@item -E, --vertical
-Print the output of a query (rows) vertically. Without this option you
-can also force this output by ending your statements with @code{\G}.
-@cindex force option
-@item -f, --force
-Continue even if we get a SQL error.
-@cindex no-named-commands option
-@item -g, --no-named-commands
-Named commands are disabled. Use \* form only, or use named commands
-only in the beginning of a line ending with a semicolon (;). Since
-Version 10.9, the client now starts with this option ENABLED by default!
-With the -g option, long format commands will still work from the first
-line, however.
-@cindex enable-named-commands option
-@item -G, --enable-named-commands
-Named commands are @strong{enabled}. Long format commands are allowed as
-well as shortened \* commands.
-@cindex ignore space option.
-@item -i, --ignore-space
-Ignore space after function names.
-@cindex host option
-@item -h, --host=...
-Connect to the given host.
-@cindex html option
-@item -H, --html
-Produce HTML output.
-@cindex skip line numbers option
-@item -L, --skip-line-numbers
-Don't write line number for errors. Useful when one wants to compare result
-files that includes error messages
-@cindex no pager option
-@item --no-pager
-Disable pager and print to stdout. See interactive help (\h) also.
-@cindex no tee option
-@item --no-tee
-Disable outfile. See interactive help (\h) also.
-@cindex unbuffered option.
-@item -n, --unbuffered
-Flush buffer after each query.
-@cindex skip column names option
-@item -N, --skip-column-names
-Don't write column names in results.
-@cindex set variable option
-@item -O, --set-variable var=option
-Give a variable a value. @code{--help} lists variables.
-@cindex one database option
-@item -o, --one-database
-Only update the default database. This is useful for skipping updates to
-other database in the update log.
-@cindex pager option
-@item @code{--pager[=...]}
-Output type. Default is your @code{ENV} variable @code{PAGER}. Valid
-pagers are less, more, cat [> filename], etc. See interactive help (\h)
-also. This option does not work in batch mode. Pager works only in UNIX.
-@cindex password option
-@item -p[password], --password[=...]
-Password to use when connecting to server. If a password is not given on
-the command line, you will be prompted for it. Note that if you use the
-short form @code{-p} you can't have a space between the option and the
-password.
-@item -P --port=...
-TCP/IP port number to use for connection.
-@cindex quick option
-@item -q, --quick
-Don't cache result, print it row-by-row. This may slow down the server
-if the output is suspended. Doesn't use history file.
-@cindex raw option
-@item -r, --raw
-Write column values without escape conversion. Used with @code{--batch}
-@cindex silent option
-@item -s, --silent
-Be more silent.
-@item -S --socket=...
-Socket file to use for connection.
-@cindex table option
-@item -t --table
-Output in table format. This is default in non-batch mode.
-@item -T, --debug-info
-Print some debug information at exit.
-@cindex tee option
-@item --tee=...
-Append everything into outfile. See interactive help (\h) also. Does not
-work in batch mode.
-@cindex user option
-@item -u, --user=#
-User for login if not current user.
-@cindex safe updates option
-@item -U, --safe-updates[=#], --i-am-a-dummy[=#]
-Only allow @code{UPDATE} and @code{DELETE} that uses keys. See below for
-more information about this option. You can reset this option if you have
-it in your @code{my.cnf} file by using @code{--safe-updates=0}.
-@cindex verbose option
-@item -v, --verbose
-More verbose output (-v -v -v gives the table output format).
-@cindex version option
-@item -V, --version
-Output version information and exit.
-@cindex wait option
-@item -w, --wait
-Wait and retry if connection is down instead of aborting.
-@end table
-
-You can also set the following variables with @code{-O} or
-@code{--set-variable}:
-
-@cindex timeout
-@multitable @columnfractions .3 .2 .5
-@item Variablename @tab Default @tab Description
-@item connect_timeout @tab 0 @tab Number of seconds before timeout connection.
-@item max_allowed_packet @tab 16777216 @tab Max packetlength to send/receive from to server
-@item net_buffer_length @tab 16384 @tab Buffer for TCP/IP and socket communication
-@item select_limit @tab 1000 @tab Automatic limit for SELECT when using --i-am-a-dummy
-@item max_join_size @tab 1000000 @tab Automatic limit for rows in a join when using --i-am-a-dummy.
-@end multitable
-
-If you type 'help' on the command line, @code{mysql} will print out the
-commands that it supports:
-
-@cindex commands, list of
-@example
-mysql> help
-
-MySQL commands:
-help (\h) Display this text.
-? (\h) Synonym for `help'.
-clear (\c) Clear command.
-connect (\r) Reconnect to the server. Optional arguments are db and host.
-edit (\e) Edit command with $EDITOR.
-ego (\G) Send command to mysql server, display result vertically.
-exit (\q) Exit mysql. Same as quit.
-go (\g) Send command to mysql server.
-nopager (\n) Disable pager, print to stdout.
-notee (\t) Don't write into outfile.
-pager (\P) Set PAGER [to_pager]. Print the query results via PAGER.
-print (\p) Print current command.
-quit (\q) Quit mysql.
-rehash (\#) Rebuild completion hash.
-source (\.) Execute a SQL script file. Takes a file name as an argument.
-status (\s) Get status information from the server.
-tee (\T) Set outfile [to_outfile]. Append everything into given outfile.
-use (\u) Use another database. Takes database name as argument.
-@end example
-
-From the above, pager only works in UNIX.
-
-@cindex status command
-The @code{status} command gives you some information about the
-connection and the server you are using. If you are running in the
-@code{--safe-updates} mode, @code{status} will also print the values for
-the @code{mysql} variables that affect your queries.
-
-@cindex @code{safe-mode} command
-A useful startup option for beginners (introduced in @strong{MySQL}
-Version 3.23.11) is @code{--safe-updates} (or @code{--i-am-a-dummy} for
-users that has at some time done a @code{DELETE FROM table_name} but
-forgot the @code{WHERE} clause). When using this option, @code{mysql}
-sends the following command to the @strong{MySQL} server when opening
-the connection:
-
-@example
-SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=#select_limit#,
- SQL_MAX_JOIN_SIZE=#max_join_size#"
-@end example
-
-where @code{#select_limit#} and @code{#max_join_size#} are variables that
-can be set from the @code{mysql} command line. @xref{SET OPTION, @code{SET}}.
-
-The effect of the above is:
-
-@itemize @bullet
-@item
-You are not allowed to do an @code{UPDATE} or @code{DELETE} statement
-if you don't have a key constraint in the @code{WHERE} part. One can,
-however, force an @code{UPDATE/DELETE} by using @code{LIMIT}:
-@example
-UPDATE table_name SET not_key_column=# WHERE not_key_column=# LIMIT 1;
-@end example
-@item
-All big results are automatically limited to @code{#select_limit#} rows.
-@item
-@code{SELECT}'s that will probably need to examine more than
-@code{#max_join_size} row combinations will be aborted.
-@end itemize
-
-Some useful hints about the @code{mysql} client:
-
-Some data is much more readable when displayed vertically, instead of
-the usual horizontal box type output. For example longer text, which
-includes new lines, is often much easier to be read with vertical
-output.
-
-@example
-mysql> select * from mails where length(txt) < 300 limit 300,1\G
-*************************** 1. row ***************************
- msg_nro: 3068
- date: 2000-03-01 23:29:50
-time_zone: +0200
-mail_from: Monty
- reply: monty@@no.spam.com
- mail_to: "Thimble Smith" <tim@@no.spam.com>
- sbj: UTF-8
- txt: >>>>> "Thimble" == Thimble Smith writes:
-
-Thimble> Hi. I think this is a good idea. Is anyone familiar with UTF-8
-Thimble> or Unicode? Otherwise I'll put this on my TODO list and see what
-Thimble> happens.
-
-Yes, please do that.
-
-Regards,
-Monty
- file: inbox-jani-1
- hash: 190402944
-1 row in set (0.09 sec)
-@end example
-
-@itemize @bullet
-@item
-For logging, you can use the @code{tee} option. The @code{tee} can be
-started with option @code{--tee=...}, or from the command line
-interactively with command @code{tee}. All the data displayed on the
-screen will also be appended into a given file. This can be very useful
-for debugging purposes also. The @code{tee} can be disabled from the
-command line with command @code{notee}. Executing @code{tee} again
-starts logging again. Without a parameter the previous file will be
-used. Note that @code{tee} will flush the results into the file after
-each command, just before the command line appears again waiting for the
-next command.
-@item
-Browsing, or searching the results in the interactive mode in UNIX less,
-more, or any other similar program, is now possible with option
-@code{--pager[=...]}. Without argument, @code{mysql} client will look
-for environment variable PAGER and set @code{pager} to that.
-@code{pager} can be started from the interactive command line with
-command @code{pager} and disabled with command @code{nopager}. The
-command takes an argument optionally and the @code{pager} will be set to
-that. Command @code{pager} can be called without an argument, but this
-requires that the option @code{--pager} was used, or the @code{pager}
-will default to stdout. @code{pager} works only in UNIX, since it uses
-the popen() function, which doesn't exist in Windows. In Windows, the
-@code{tee} option can be used instead, although it may not be as handy
-as @code{pager} can be in some situations.
-@item
-A few tips about @code{pager}: You can use it to write to a file:
-@example
-mysql> pager cat > /tmp/log.txt
-@end example
-and the results will only go to a file. You can also pass any options
-for the programs that you want to use with the @code{pager}:
-@example
-mysql> pager less -n -i -S
-@end example
-From the above do note the option '-S'. You may find it very useful when
-browsing the results; try the option with horizontal output (end
-commands with '\g', or ';') and with vertical output (end commands with
-'\G'). Sometimes a very wide result set is hard to be read from the screen,
-with option -S to less you can browse the results within the interactive
-less from left to right, preventing lines longer than your screen from
-being continued to the next line. This can make the result set much more
-readable. You can swith the mode between on and off within the interactive
-less with '-S'. See the 'h' for more help about less.
-@item
-Last (unless you already understood this from the above examples ;) you
-can combine very complex ways to handle the results, for example the
-following would send the results to two files in two different
-directories, on two different hard-disks mounted on /dr1 and /dr2, yet
-let the results still be seen on the screen via less:
-@example
-mysql> pager cat | tee /dr1/tmp/res.txt | tee /dr2/tmp/res2.txt | less -n -i -S
-@end example
-@item
-You can also combine the two functions above; have the @code{tee}
-enabled, @code{pager} set to 'less' and you will be able to browse the
-results in unix 'less' and still have everything appended into a file
-the same time. The difference between @code{UNIX tee} used with the
-@code{pager} and the @code{mysql} client in-built @code{tee}, is that
-the in-built @code{tee} works even if you don't have the @code{UNIX tee}
-available. The in-built @code{tee} also logs everything that is printed
-on the screen, where the @code{UNIX tee} used with @code{pager} doesn't
-log quite that much. Last, but not least, the interactive @code{tee} is
-more handy to switch on and off, when you want to log something into a
-file, but want to be able to turn the feature off sometimes.
-@end itemize
-
-
-@cindex administration, server
-@cindex server administration
-@cindex @code{mysladmn}
-@node mysqladmin, mysqldump, mysql, Tools
-@section Administering a MySQL Server
-
-A utility for performing administrative operations. The syntax is:
-
-@example
-shell> mysqladmin [OPTIONS] command [command-option] command ...
-@end example
-
-You can get a list of the options your version of @code{mysqladmin} supports
-by executing @code{mysqladmin --help}.
-
-The current @code{mysqladmin} supports the following commands:
-
-@multitable @columnfractions .3 .7
-@item create databasename @tab Create a new database.
-@item drop databasename @tab Delete a database and all its tables.
-@item extended-status @tab Gives an extended status message from the server.
-@item flush-hosts @tab Flush all cached hosts.
-@item flush-logs @tab Flush all logs.
-@item flush-tables @tab Flush all tables.
-@item flush-privileges @tab Reload grant tables (same as reload).
-@item kill id,id,... @tab Kill mysql threads.
-@item password @tab New-password. Change old password to new-password.
-@item ping @tab Check if @code{mysqld} is alive.
-@item processlist @tab Show list of active threads in server.
-@item reload @tab Reload grant tables.
-@item refresh @tab Flush all tables and close and open logfiles.
-@item shutdown @tab Take server down.
-@item slave-start @tab Start slave replication thread.
-@item slave-stop @tab Stop slave replication thread.
-@item status @tab Gives a short status message from the server.
-@item variables @tab Prints variables available.
-@item version @tab Get version info from server.
-@end multitable
-
-All commands can be shortened to their unique prefix. For example:
-
-@example
-shell> mysqladmin proc stat
-+----+-------+-----------+----+-------------+------+-------+------+
-| Id | User | Host | db | Command | Time | State | Info |
-+----+-------+-----------+----+-------------+------+-------+------+
-| 6 | monty | localhost | | Processlist | 0 | | |
-+----+-------+-----------+----+-------------+------+-------+------+
-Uptime: 10077 Threads: 1 Questions: 9 Slow queries: 0 Opens: 6 Flush tables: 1 Open tables: 2 Memory in use: 1092K Max memory used: 1116K
-@end example
-
-@cindex status command, results
-The @code{mysqladmin status} command result has the following columns:
-
-@cindex uptime
-@multitable @columnfractions .3 .7
-@item Uptime @tab Number of seconds the @strong{MySQL} server has been up.
-@cindex threads
-@item Threads @tab Number of active threads (clients).
-@cindex questions
-@item Questions @tab Number of questions from clients since @code{mysqld} was started.
-@cindex slow queries
-@item Slow queries @tab Queries that have taken more than @code{long_query_time} seconds. @xref{Slow query log}.
-@cindex opens
-@item Opens @tab How many tables @code{mysqld} has opened.
-@cindex flush tables
-@cindex tables, flush
-@item Flush tables @tab Number of @code{flush ...}, @code{refresh}, and @code{reload} commands.
-@cindex open tables
-@item Open tables @tab Number of tables that are open now.
-@cindex memory use
-@item Memory in use @tab Memory allocated directly by the @code{mysqld} code (only available when @strong{MySQL} is compiled with --with-debug=full).
-@cindex max memory used
-@item Max memory used @tab Maximum memory allocated directly by the @code{mysqld} code (only available when @strong{MySQL} is compiled with --with-debug=full).
-@end multitable
-
-If you do @code{myslqadmin shutdown} on a socket (in other words, on a
-the computer where @code{mysqld} is running), @code{mysqladmin} will
-wait until the @strong{MySQL} @code{pid-file} is removed to ensure that
-the @code{mysqld} server has stopped properly.
-
-@cindex dumping, databases
-@cindex databases, dumping
-@cindex tables, dumping
-@cindex backing up, databases
-@node mysqldump, mysqlhotcopy, mysqladmin, Tools
-@section Dumping the Structure and Data from MySQL Databases and Tables
-
-@cindex @code{mysqldump}
-Utility to dump a database or a collection of database for backup or for
-transferring the data to another SQL server (not necessarily a @strong{MySQL}
-server). The dump will contain SQL statements to create the table
-and/or populate the table.
-
-If you are doing a backup on the server, you should consider using
-the @code{mysqlhotcopy} instead. @xref{mysqlhotcopy, , @code{mysqlhotcopy}}.
-
-@example
-shell> mysqldump [OPTIONS] database [tables]
-OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
-OR mysqldump [OPTIONS] --all-databases [OPTIONS]
-@end example
-
-If you don't give any tables or use the @code{--databases} or
-@code{--all-databases}, the whole database(s) will be dumped.
-
-You can get a list of the options your version of @code{mysqldump} supports
-by executing @code{mysqldump --help}.
-
-Note that if you run @code{mysqldump} without @code{--quick} or
-@code{--opt}, @code{mysqldump} will load the whole result set into
-memory before dumping the result. This will probably be a problem if
-you are dumping a big database.
-
-Note that if you are using a new copy of the @code{mysqldump} program
-and you are going to do a dump that will be read into a very old @strong{MySQL}
-server, you should not use the @code{--opt} or @code{-e} options.
-
-@code{mysqldump} supports the following options:
-
-@table @code
-@item --add-locks
-Add @code{LOCK TABLES} before and @code{UNLOCK TABLE} after each table dump.
-(To get faster inserts into @strong{MySQL}.)
-@item --add-drop-table
-Add a @code{drop table} before each create statement.
-@item -A, --all-databases
-Dump all the databases. This will be same as @code{--databases} with all
-databases selected.
-@item -a, --all
-Include all @strong{MySQL}-specific create options.
-@item --allow-keywords
-Allow creation of column names that are keywords. This works by
-prefixing each column name with the table name.
-@item -c, --complete-insert
-Use complete insert statements (with column names).
-@item -C, --compress
-Compress all information between the client and the server if both support
-compression.
-@item -B, --databases
-To dump several databases. Note the difference in usage. In this case
-no tables are given. All name arguments are regarded as database names.
-@code{USE db_name;} will be included in the output before each new database.
-@item --delayed
-Insert rows with the @code{INSERT DELAYED} command.
-@item -e, --extended-insert
-Use the new multiline @code{INSERT} syntax. (Gives more compact and
-faster inserts statements.)
-@item -#, --debug[=option_string]
-Trace usage of the program (for debugging).
-@item --help
-Display a help message and exit.
-@item --fields-terminated-by=...
-@itemx --fields-enclosed-by=...
-@itemx --fields-optionally-enclosed-by=...
-@itemx --fields-escaped-by=...
-@itemx --lines-terminated-by=...
-These options are used with the @code{-T} option and have the same
-meaning as the corresponding clauses for @code{LOAD DATA INFILE}.
-@xref{LOAD DATA, , @code{LOAD DATA}}.
-@item -F, --flush-logs
-Flush log file in the @strong{MySQL} server before starting the dump.
-@item -f, --force,
-Continue even if we get a SQL error during a table dump.
-@item -h, --host=..
-Dump data from the @strong{MySQL} server on the named host. The default host
-is @code{localhost}.
-@item -l, --lock-tables.
-Lock all tables before starting the dump. The tables are locked with
-@code{READ LOCAL} to allow concurrent inserts in the case of @code{MyISAM}
-tables.
-@item -n, --no-create-db
-'CREATE DATABASE /*!32312 IF NOT EXISTS*/ db_name;' will not be put in the
-output. The above line will be added otherwise, if --databases or
---all-databases option was given.
-@item -t, --no-create-info
-Don't write table creation information (The @code{CREATE TABLE} statement.)
-@item -d, --no-data
-Don't write any row information for the table. This is very useful if you
-just want to get a dump of the structure for a table!
-@item --opt
-Same as @code{--quick --add-drop-table --add-locks --extended-insert
---lock-tables}. Should give you the fastest possible dump for reading
-into a @strong{MySQL} server.
-@item -pyour_pass, --password[=your_pass]
-The password to use when connecting to the server. If you specify
-no @samp{=your_pass} part,
-@code{mysqldump} you will be prompted for a password.
-@item -P port_num, --port=port_num
-The TCP/IP port number to use for connecting to a host. (This is used for
-connections to hosts other than @code{localhost}, for which Unix sockets are
-used.)
-@item -q, --quick
-Don't buffer query, dump directly to stdout. Uses @code{mysql_use_result()}
-to do this.
-@item -r, --result-file=...
-Direct output to a given file. This option should be used in MSDOS,
-because it prevents new line '\n' from being converted to '\n\r' (new
-line + carriage return).
-@item -S /path/to/socket, --socket=/path/to/socket
-The socket file to use when connecting to @code{localhost} (which is the
-default host).
-@item --tables
-Overrides option --databases (-B).
-@item -T, --tab=path-to-some-directory
-Creates a @code{table_name.sql} file, that contains the SQL CREATE commands,
-and a @code{table_name.txt} file, that contains the data, for each give table.
-@strong{NOTE}: This only works if @code{mysqldump} is run on the same
-machine as the @code{mysqld} daemon. The format of the @code{.txt} file
-is made according to the @code{--fields-xxx} and @code{--lines--xxx} options.
-@item -u user_name, --user=user_name
-The @strong{MySQL} user name to use when connecting to the server. The
-default value is your Unix login name.
-@item -O var=option, --set-variable var=option
-Set the value of a variable. The possible variables are listed below.
-@item -v, --verbose
-Verbose mode. Print out more information on what the program does.
-@item -V, --version
-Print version information and exit.
-@item -w, --where='where-condition'
-Dump only selected records. Note that QUOTES are mandatory:
-
-@example
-"--where=user='jimf'" "-wuserid>1" "-wuserid<1"
-@end example
-@item -O net_buffer_length=#, where # < 16M
-When creating multi-row-insert statements (as with option
-@code{--extended-insert} or @code{--opt}), @code{mysqldump} will create
-rows up to @code{net_buffer_length} length. If you increase this
-variable, you should also ensure that the @code{max_allowed_packet}
-variable in the @strong{MySQL} server is bigger than the
-@code{net_buffer_length}.
-@end table
-
-The most normal use of @code{mysqldump} is probably for making a backup of
-whole databases. @xref{Backup}.
-
-@example
-mysqldump --opt database > backup-file.sql
-@end example
-
-You can read this back into @strong{MySQL} with:
-
-@example
-mysql database < backup-file.sql
-@end example
-
-or
-
-@example
-mysql -e "source /patch-to-backup/backup-file.sql" database
-@end example
-
-However, it's also very useful to populate another @strong{MySQL} server with
-information from a database:
-
-@example
-mysqldump --opt database | mysql ---host=remote-host -C database
-@end example
-
-It is possible to dump several databases with one command:
-
-@example
-mysqldump --databases database1 [database2 database3...] > my_databases.sql
-@end example
-
-If all the databases are wanted, one can use:
-
-@example
-mysqldump --all-databases > all_databases.sql
-@end example
-
-@cindex dumping, databases
-@cindex databases, dumping
-@cindex tables, dumping
-@cindex backing up, databases
-@node mysqlhotcopy, mysqlimport, mysqldump, Tools
-@section Copying MySQL Databases and Tables
-
-@code{mysqlhotcopy} is a perl script that uses @code{LOCK TABLES},
-@code{FLUSH TABLES} and @code{cp} or @code{scp} to quickly make a backup
-of a database. It's the fastest way to make a backup of the database,
-of single tables but it can only be run on the same machine where the
-database directories are.
-
-@example
-mysqlhotcopy db_name [/path/to/new_directory]
-
-mysqlhotcopy db_name_1 ... db_name_n /path/to/new_directory
-
-mysqlhotcopy db_name./regex/
-@end example
-
-@code{mysqlhotcopy} supports the following options:
-
-@table @code
-@item -?, --help
-Display a help screen and exit
-@item -u, --user=#
-User for database login
-@item -p, --password=#
-Password to use when connecting to server
-@item -P, --port=#
-Port to use when connecting to local server
-@item -S, --socket=#
-Socket to use when connecting to local server
-@item --allowold
-Don't abort if target already exists (rename it _old)
-@item --keepold
-Don't delete previous (now renamed) target when done
-@item --noindices
-Don't include full index files in copy to make the backup smaller and faster
-The indexes can later be reconstructed with @code{myisamchk -rq.}.
-@item --method=#
-Method for copy (@code{cp} or @code{scp}).
-@item -q, --quiet
-Be silent except for errors
-@item --debug
-Enable debug
-@item -n, --dryrun
-Report actions without doing them
-@item --regexp=#
-Copy all databases with names matching regexp
-@item --suffix=#
-Suffix for names of copied databases
-@item --checkpoint=#
-Insert checkpoint entry into specified db.table
-@item --flushlog
-Flush logs once all tables are locked.
-@item --tmpdir=#
-Temporary directory (instead of /tmp).
-@end table
-
-You can use @code{perldoc mysqlhotcopy} to get a more complete
-documentation for @code{mysqlhotcopy}.
-
-@code{mysqlhotcopy} reads the groups @code{[client]} and @code{[mysqlhotcopy]}
-from the option files.
-
-To be able to execute @code{mysqlhotcopy} you need write access to the
-backup directory, @code{SELECT} privilege to the tables you are about to
-copy and the @strong{MySQL} @code{Reload} privilege (to be able to
-execute @code{FLUSH TABLES}).
-
-@cindex importing, data
-@cindex data, importing
-@cindex files, text
-@cindex text files, importing
-@cindex @code{mysqlimport}
-@node mysqlimport, perror, mysqlhotcopy, Tools
-@section Importing Data from Text Files
-
-@code{mysqlimport} provides a command-line interface to the @code{LOAD DATA
-INFILE} SQL statement. Most options to @code{mysqlimport} correspond
-directly to the same options to @code{LOAD DATA INFILE}.
-@xref{LOAD DATA, , @code{LOAD DATA}}.
-
-@code{mysqlimport} is invoked like this:
-
-@example
-shell> mysqlimport [options] database textfile1 [textfile2....]
-@end example
-
-For each text file named on the command line,
-@code{mysqlimport} strips any extension from the filename and uses the result
-to determine which table to import the file's contents into. For example,
-files named @file{patient.txt}, @file{patient.text}, and @file{patient} would
-all be imported into a table named @code{patient}.
-
-@code{mysqlimport} supports the following options:
-
-@table @code
-@item -c, --columns=...
-This option takes a comma-separated list of field names as an argument.
-The field list is used to create a proper @code{LOAD DATA INFILE} command,
-which is then passed to @strong{MySQL}. @xref{LOAD DATA, , @code{LOAD DATA}}.
-
-@item -C, --compress
-Compress all information between the client and the server if both support
-compression.
-
-@item -#, --debug[=option_string]
-Trace usage of the program (for debugging).
-
-@item -d, --delete
-Empty the table before importing the text file.
-
-@item --fields-terminated-by=...
-@itemx --fields-enclosed-by=...
-@itemx --fields-optionally-enclosed-by=...
-@itemx --fields-escaped-by=...
-@itemx --lines-terminated-by=...
-These options have the same meaning as the corresponding clauses for
-@code{LOAD DATA INFILE}. @xref{LOAD DATA, , @code{LOAD DATA}}.
-
-@item -f, --force
-Ignore errors. For example, if a table for a text file doesn't exist,
-continue processing any remaining files. Without @code{--force},
-@code{mysqlimport} exits if a table doesn't exist.
-
-@item --help
-Display a help message and exit.
-
-@item -h host_name, --host=host_name
-Import data to the @strong{MySQL} server on the named host. The default host
-is @code{localhost}.
-
-@item -i, --ignore
-See the description for the @code{--replace} option.
-
-@item -l, --lock-tables
-Lock @strong{ALL} tables for writing before processing any text files. This
-ensures that all tables are synchronized on the server.
-
-@item -L, --local
-Read input files from the client. By default, text files are assumed to be on
-the server if you connect to @code{localhost} (which is the default host).
-
-@item -pyour_pass, --password[=your_pass]
-The password to use when connecting to the server. If you specify
-no @samp{=your_pass} part,
-@code{mysqlimport} you will be prompted for a password.
-
-@item -P port_num, --port=port_num
-The TCP/IP port number to use for connecting to a host. (This is used for
-connections to hosts other than @code{localhost}, for which Unix sockets are
-used.)
-
-@item -r, --replace
-The @code{--replace} and @code{--ignore} options control handling of input
-records that duplicate existing records on unique key values. If you specify
-@code{--replace}, new rows replace existing rows that have the same unique key
-value. If you specify @code{--ignore}, input rows that duplicate an existing
-row on a unique key value are skipped. If you don't specify either option, an
-error occurs when a duplicate key value is found, and the rest of the text
-file is ignored.
-
-@item -s, --silent
-Silent mode. Write output only when errors occur.
-
-@item -S /path/to/socket, --socket=/path/to/socket
-The socket file to use when connecting to @code{localhost} (which is the
-default host).
-
-@item -u user_name, --user=user_name
-The @strong{MySQL} user name to use when connecting to the server. The
-default value is your Unix login name.
-
-@item -v, --verbose
-Verbose mode. Print out more information what the program does.
-
-@item -V, --version
-Print version information and exit.
-@end table
-
-Here is a sample run using @code{mysqlimport}:
-
-@example
-$ mysql --version
-mysql Ver 9.33 Distrib 3.22.25, for pc-linux-gnu (i686)
-$ uname -a
-Linux xxx.com 2.2.5-15 #1 Mon Apr 19 22:21:09 EDT 1999 i586 unknown
-$ mysql -e 'CREATE TABLE imptest(id INT, n VARCHAR(30))' test
-$ ed
-a
-100 Max Sydow
-101 Count Dracula
-.
-w imptest.txt
-32
-q
-$ od -c imptest.txt
-0000000 1 0 0 \t M a x S y d o w \n 1 0
-0000020 1 \t C o u n t D r a c u l a \n
-0000040
-$ mysqlimport --local test imptest.txt
-test.imptest: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0
-$ mysql -e 'SELECT * FROM imptest' test
-+------+---------------+
-| id | n |
-+------+---------------+
-| 100 | Max Sydow |
-| 101 | Count Dracula |
-+------+---------------+
-@end example
-
-@cindex error messages, displaying
-@cindex perror
-@node perror, mysqlshow, mysqlimport, Tools
-@section Converting an error code to the corresponding error message
-
-@code{perror} can be used to print error message(s). @code{perror} can
-be invoked like this:
-
-@example
-shell> perror [OPTIONS] [ERRORCODE [ERRORCODE...]]
-
-For example:
-
-shell> perror 64 79
-Error code 64: Machine is not on the network
-Error code 79: Can not access a needed shared library
-@end example
-
-@code{perror} can be used to display a description for a system error
-code, or an MyISAM/ISAM table handler error code. The error messages
-are mostly system dependent.
-
-@cindex databases, displaying
-@cindex displaying, database information
-@cindex tables, displaying
-@cindex columns, displaying
-@cindex showing, database information
-@node mysqlshow, myisampack, perror, Tools
-@section Showing Databases, Tables, and Columns
-
-@code{mysqlshow} can be used to quickly look at which databases exist,
-their tables, and the table's columns.
-
-With the @code{mysql} program you can get the same information with the
-@code{SHOW} commands. @xref{SHOW}.
-
-@code{mysqlshow} is invoked like this:
-
-@example
-shell> mysqlshow [OPTIONS] [database [table [column]]]
-@end example
-
-@itemize @bullet
-@item
-If no database is given, all matching databases are shown.
-@item
-If no table is given, all matching tables in the database are shown.
-@item
-If no column is given, all matching columns and column types in the table
-are shown.
-@end itemize
-
-Note that in newer @strong{MySQL} versions, you only see those
-database/tables/columns for which you have some privileges.
-
-If the last argument contains a shell or SQL wild-card (@code{*}, @code{?},
-@code{%} or @code{_}) then only what's matched by the wild card is shown.
-This may cause some confusion when you try to display the columns for a
-table with a @code{_} as in this case @code{mysqlshow} only shows you
-the table names that match the pattern. This is easily fixed by
-adding an extra @code{%} last on the command line (as a separate
-argument).
-
-@cindex compressed tables
-@cindex tables, compressed
-@cindex MyISAM, compressed tables
-@cindex @code{myisampack}
-@cindex @code{pack_isam}
-@node myisampack, , mysqlshow, Tools
-@section The MySQL Compressed Read-only Table Generator
-
-@code{myisampack} is used to compress MyISAM tables, and @code{pack_isam}
-is used to compress ISAM tables. Because ISAM tables are deprecated, we
-will only discuss @code{myisampack} here, but everything said about
-@code{myisampack} should also be true for @code{pack_isam}.
-
-@code{myisampack} works by compressing each column in the table separately.
-The information needed to decompress columns is read into memory when the
-table is opened. This results in much better performance when accessing
-individual records, because you only have to uncompress exactly one record, not
-a much larger disk block as when using Stacker on MS-DOS.
-Usually, @code{myisampack} packs the data file 40%-70%.
-
-@strong{MySQL} uses memory mapping (@code{mmap()}) on compressed tables and
-falls back to normal read/write file usage if @code{mmap()} doesn't work.
-
-There are currently two limitations with @code{myisampack}:
-@itemize @bullet
-@item
-After packing, the table is read-only.
-@item
-@code{myisampack} can also pack @code{BLOB} or @code{TEXT} columns. The
-older @code{pack_isam} could not do this.
-@end itemize
-
-Fixing these limitations is on our TODO list but with low priority.
-
-@code{myisampack} is invoked like this:
-
-@example
-shell> myisampack [options] filename ...
-@end example
-
-Each filename should be the name of an index (@file{.MYI}) file. If you
-are not in the database directory, you should specify the pathname to the
-file. It is permissible to omit the @file{.MYI} extension.
-
-@code{myisampack} supports the following options:
-
-@table @code
-@item -b, --backup
-Make a backup of the table as @code{tbl_name.OLD}.
-
-@item -#, --debug=debug_options
-Output debug log. The @code{debug_options} string often is
-@code{'d:t:o,filename'}.
-
-@item -f, --force
-Force packing of the table even if it becomes bigger or if the temporary file
-exists. @code{myisampack} creates a temporary file named @file{tbl_name.TMD}
-while it compresses the table. If you kill @code{myisampack}, the @file{.TMD}
-file may not be deleted. Normally, @code{myisampack} exits with an error if
-it finds that @file{tbl_name.TMD} exists. With @code{--force},
-@code{myisampack} packs the table anyway.
-
-@item -?, --help
-Display a help message and exit.
-
-@item -j big_tbl_name, --join=big_tbl_name
-Join all tables named on the command line into a single table
-@code{big_tbl_name}. All tables that are to be combined
-MUST be identical (same column names and types, same indexes, etc.).
-
-@item -p #, --packlength=#
-Specify the record length storage size, in bytes. The value should be 1, 2,
-or 3. (@code{myisampack} stores all rows with length pointers of 1, 2, or 3
-bytes. In most normal cases, @code{myisampack} can determine the right length
-value before it begins packing the file, but it may notice during the packing
-process that it could have used a shorter length. In this case,
-@code{myisampack} will print a note that the next time you pack the same file,
-you could use a shorter record length.)
-
-@item -s, --silent
-Silent mode. Write output only when errors occur.
-
-@item -t, --test
-Don't actually pack table, just test packing it.
-
-@item -T dir_name, --tmp_dir=dir_name
-Use the named directory as the location in which to write the temporary table.
-
-@item -v, --verbose
-Verbose mode. Write information about progress and packing result.
-
-@item -V, --version
-Display version information and exit.
-
-@item -w, --wait
-
-Wait and retry if table is in use. If the @code{mysqld} server was
-invoked with the @code{--skip-locking} option, it is not a good idea to
-invoke @code{myisampack} if the table might be updated during the
-packing process.
-@end table
-
-@cindex examples, compressed tables
-The sequence of commands shown below illustrates a typical table compression
-session:
-
-@example
-shell> ls -l station.*
--rw-rw-r-- 1 monty my 994128 Apr 17 19:00 station.MYD
--rw-rw-r-- 1 monty my 53248 Apr 17 19:00 station.MYI
--rw-rw-r-- 1 monty my 5767 Apr 17 19:00 station.frm
-
-shell> myisamchk -dvv station
-
-MyISAM file: station
-Isam-version: 2
-Creation time: 1996-03-13 10:08:58
-Recover time: 1997-02-02 3:06:43
-Data records: 1192 Deleted blocks: 0
-Datafile: Parts: 1192 Deleted data: 0
-Datafile pointer (bytes): 2 Keyfile pointer (bytes): 2
-Max datafile length: 54657023 Max keyfile length: 33554431
-Recordlength: 834
-Record format: Fixed length
-
-table description:
-Key Start Len Index Type Root Blocksize Rec/key
-1 2 4 unique unsigned long 1024 1024 1
-2 32 30 multip. text 10240 1024 1
-
-Field Start Length Type
-1 1 1
-2 2 4
-3 6 4
-4 10 1
-5 11 20
-6 31 1
-7 32 30
-8 62 35
-9 97 35
-10 132 35
-11 167 4
-12 171 16
-13 187 35
-14 222 4
-15 226 16
-16 242 20
-17 262 20
-18 282 20
-19 302 30
-20 332 4
-21 336 4
-22 340 1
-23 341 8
-24 349 8
-25 357 8
-26 365 2
-27 367 2
-28 369 4
-29 373 4
-30 377 1
-31 378 2
-32 380 8
-33 388 4
-34 392 4
-35 396 4
-36 400 4
-37 404 1
-38 405 4
-39 409 4
-40 413 4
-41 417 4
-42 421 4
-43 425 4
-44 429 20
-45 449 30
-46 479 1
-47 480 1
-48 481 79
-49 560 79
-50 639 79
-51 718 79
-52 797 8
-53 805 1
-54 806 1
-55 807 20
-56 827 4
-57 831 4
-
-shell> myisampack station.MYI
-Compressing station.MYI: (1192 records)
-- Calculating statistics
-
-normal: 20 empty-space: 16 empty-zero: 12 empty-fill: 11
-pre-space: 0 end-space: 12 table-lookups: 5 zero: 7
-Original trees: 57 After join: 17
-- Compressing file
-87.14%
-
-shell> ls -l station.*
--rw-rw-r-- 1 monty my 127874 Apr 17 19:00 station.MYD
--rw-rw-r-- 1 monty my 55296 Apr 17 19:04 station.MYI
--rw-rw-r-- 1 monty my 5767 Apr 17 19:00 station.frm
-
-shell> myisamchk -dvv station
-
-MyISAM file: station
-Isam-version: 2
-Creation time: 1996-03-13 10:08:58
-Recover time: 1997-04-17 19:04:26
-Data records: 1192 Deleted blocks: 0
-Datafile: Parts: 1192 Deleted data: 0
-Datafilepointer (bytes): 3 Keyfile pointer (bytes): 1
-Max datafile length: 16777215 Max keyfile length: 131071
-Recordlength: 834
-Record format: Compressed
-
-table description:
-Key Start Len Index Type Root Blocksize Rec/key
-1 2 4 unique unsigned long 10240 1024 1
-2 32 30 multip. text 54272 1024 1
-
-Field Start Length Type Huff tree Bits
-1 1 1 constant 1 0
-2 2 4 zerofill(1) 2 9
-3 6 4 no zeros, zerofill(1) 2 9
-4 10 1 3 9
-5 11 20 table-lookup 4 0
-6 31 1 3 9
-7 32 30 no endspace, not_always 5 9
-8 62 35 no endspace, not_always, no empty 6 9
-9 97 35 no empty 7 9
-10 132 35 no endspace, not_always, no empty 6 9
-11 167 4 zerofill(1) 2 9
-12 171 16 no endspace, not_always, no empty 5 9
-13 187 35 no endspace, not_always, no empty 6 9
-14 222 4 zerofill(1) 2 9
-15 226 16 no endspace, not_always, no empty 5 9
-16 242 20 no endspace, not_always 8 9
-17 262 20 no endspace, no empty 8 9
-18 282 20 no endspace, no empty 5 9
-19 302 30 no endspace, no empty 6 9
-20 332 4 always zero 2 9
-21 336 4 always zero 2 9
-22 340 1 3 9
-23 341 8 table-lookup 9 0
-24 349 8 table-lookup 10 0
-25 357 8 always zero 2 9
-26 365 2 2 9
-27 367 2 no zeros, zerofill(1) 2 9
-28 369 4 no zeros, zerofill(1) 2 9
-29 373 4 table-lookup 11 0
-30 377 1 3 9
-31 378 2 no zeros, zerofill(1) 2 9
-32 380 8 no zeros 2 9
-33 388 4 always zero 2 9
-34 392 4 table-lookup 12 0
-35 396 4 no zeros, zerofill(1) 13 9
-36 400 4 no zeros, zerofill(1) 2 9
-37 404 1 2 9
-38 405 4 no zeros 2 9
-39 409 4 always zero 2 9
-40 413 4 no zeros 2 9
-41 417 4 always zero 2 9
-42 421 4 no zeros 2 9
-43 425 4 always zero 2 9
-44 429 20 no empty 3 9
-45 449 30 no empty 3 9
-46 479 1 14 4
-47 480 1 14 4
-48 481 79 no endspace, no empty 15 9
-49 560 79 no empty 2 9
-50 639 79 no empty 2 9
-51 718 79 no endspace 16 9
-52 797 8 no empty 2 9
-53 805 1 17 1
-54 806 1 3 9
-55 807 20 no empty 3 9
-56 827 4 no zeros, zerofill(2) 2 9
-57 831 4 no zeros, zerofill(1) 2 9
-@end example
-
-The information printed by @code{myisampack} is described below:
-
-@table @code
-@item normal
-The number of columns for which no extra packing is used.
-
-@item empty-space
-The number of columns containing
-values that are only spaces; these will occupy 1 bit.
-
-@item empty-zero
-The number of columns containing
-values that are only binary 0's; these will occupy 1 bit.
-
-@item empty-fill
-The number of integer columns that don't occupy the full byte range of their
-type; these are changed to a smaller type (for example, an @code{INTEGER}
-column may be changed to @code{MEDIUMINT}).
-
-@item pre-space
-The number of decimal columns that are stored with leading spaces. In this
-case, each value will contain a count for the number of leading spaces.
-
-@item end-space
-The number of columns that have a lot of trailing spaces. In this case, each
-value will contain a count for the number of trailing spaces.
-
-@item table-lookup
-The column had only a small number of different values, which were
-converted to an @code{ENUM} before Huffman compression.
-
-@item zero
-The number of columns for which all values are zero.
-
-@item Original trees
-The initial number of Huffman trees.
-
-@item After join
-The number of distinct Huffman trees left after joining
-trees to save some header space.
-@end table
-
-After a table has been compressed, @code{myisamchk -dvv} prints additional
-information about each field:
-
-@table @code
-@item Type
-The field type may contain the following descriptors:
-
-@table @code
-@item constant
-All rows have the same value.
-
-@item no endspace
-Don't store endspace.
-
-@item no endspace, not_always
-Don't store endspace and don't do end space compression for all values.
-
-@item no endspace, no empty
-Don't store endspace. Don't store empty values.
-
-@item table-lookup
-The column was converted to an @code{ENUM}.
-
-@item zerofill(n)
-The most significant @code{n} bytes in the value are always 0 and are not
-stored.
-
-@item no zeros
-Don't store zeros.
-
-@item always zero
-0 values are stored in 1 bit.
-@end table
-
-@item Huff tree
-The Huffman tree associated with the field.
-
-@item Bits
-The number of bits used in the Huffman tree.
-@end table
-
-After you have run @code{pack_isam}/@code{myisampack} you must run
-@code{isamchk}/@code{myisamchk} to re-create the index. At this time you
-can also sort the index blocks and create statistics needed for
-the @strong{MySQL} optimizer to work more efficiently:
-
-@example
-myisamchk -rq --analyze --sort-index table_name.MYI
-isamchk -rq --analyze --sort-index table_name.ISM
-@end example
-
-After you have installed the packed table into the @strong{MySQL} database
-directory you should do @code{mysqladmin flush-tables} to force @code{mysqld}
-to start using the new table.
-
-If you want to unpack a packed table, you can do this with the
-@code{--unpack} option to @code{isamchk} or @code{myisamchk}.
+@node Maintenance, Adding functions, MySQL Benchmarks, Top
+@chapter Maintaining a MySQL Installation
@cindex installation maintenance
@cindex maintaining, tables
@@ -34074,406 +36594,19 @@ If you want to unpack a packed table, you can do this with the
@cindex @code{mysqlcheck}
@cindex crash, recovery
@cindex recovery, from crash
-@node Maintenance, Adding functions, Tools, Top
-@chapter Maintaining a MySQL Installation
+
@menu
-* Table maintenance:: Table maintenance and crash recovery
* Using mysqlcheck:: Using mysqlcheck for maintenance and recovery
-* Maintenance regimen:: Setting up a table maintenance regimen
-* Table-info:: Getting information about a table
-* Crash recovery:: Using @code{myisamchk} for crash recovery
-* Log file maintenance:: Log file maintenance
@end menu
This chapter covers what you should know about maintaining a @strong{MySQL}
distribution. You will learn how to care for your tables on a regular
basis, and what to do when disaster strikes.
-@node Table maintenance, Using mysqlcheck, Maintenance, Maintenance
-@section Using @code{myisamchk} for Table Maintenance and Crash Recovery
-
-Starting with @strong{MySQL} Version 3.23.13, you can check MyISAM
-tables with the @code{CHECK TABLE} command. @xref{CHECK TABLE}. You can
-repair tables with the @code{REPAIR TABLE} command. @xref{REPAIR TABLE}.
-
-To check/repair MyISAM tables (@code{.MYI} and @code{.MYD}) you should
-use the @code{myisamchk} utility. To check/repair ISAM tables
-(@code{.ISM} and @code{.ISD}) you should use the @code{isamchk}
-utility. @xref{Table types}.
-
-In the following text we will talk about @code{myisamchk}, but everything
-also applies to the old @code{isamchk}.
-
-You can use the @code{myisamchk} utility to get information about your
-database tables, check and repair them, or optimize them. The following
-sections describe how to invoke @code{myisamchk} (including a
-description of its options), how to set up a table maintenance schedule,
-and how to use @code{myisamchk} to perform its various functions.
-
-You can, in most cases, also use the command @code{OPTIMIZE TABLES} to
-optimize and repair tables, but this is not as fast or reliable (in case
-of real fatal errors) as @code{myisamchk}. On the other hand,
-@code{OPTIMIZE TABLE} is easier to use and you don't have to worry about
-flushing tables.
-@xref{OPTIMIZE TABLE, , @code{OPTIMIZE TABLE}}.
-
-Even that the repair in @code{myisamchk} is quite secure, it's always a
-good idea to make a backup BEFORE doing a repair (or anything that could
-make a lot of changes to a table)
-
-@menu
-* myisamchk syntax:: @code{myisamchk} invocation syntax
-* myisamchk memory:: @code{myisamchk} memory usage
-@end menu
-
-@node myisamchk syntax, myisamchk memory, Table maintenance, Table maintenance
-@subsection @code{myisamchk} Invocation Syntax
-
-@code{myisamchk} is invoked like this:
-
-@example
-shell> myisamchk [options] tbl_name
-@end example
-
-The @code{options} specify what you want @code{myisamchk} to do. They are
-described below. (You can also get a list of options by invoking
-@code{myisamchk --help}.) With no options, @code{myisamchk} simply checks your
-table. To get more information or to tell @code{myisamchk} to take corrective
-action, specify options as described below and in the following sections.
-
-@code{tbl_name} is the database table you want to check/repair. If you run
-@code{myisamchk} somewhere other than in the database directory, you must
-specify the path to the file, because @code{myisamchk} has no idea where your
-database is located. Actually, @code{myisamchk} doesn't care whether or not
-the files you are working on are located in a database directory; you can
-copy the files that correspond to a database table into another location and
-perform recovery operations on them there.
-
-You can name several tables on the @code{myisamchk} command line if you
-wish. You can also specify a name as an index file
-name (with the @file{.MYI} suffix), which allows you to specify all
-tables in a directory by using the pattern @file{*.MYI}.
-For example, if you are in a database directory, you can check all the
-tables in the directory like this:
-
-@example
-shell> myisamchk *.MYI
-@end example
-
-If you are not in the database directory, you can check all the tables there
-by specifying the path to the directory:
-
-@example
-shell> myisamchk /path/to/database_dir/*.MYI
-@end example
-
-You can even check all tables in all databases by specifying a wild card
-with the path to the @strong{MySQL} data directory:
-
-@example
-shell> myisamchk /path/to/datadir/*/*.MYI
-@end example
-
-The recommended way to quickly check all tables is:
-
-@example
-myisamchk --silent --fast /path/to/datadir/*/*.MYI
-isamchk --silent /path/to/datadir/*/*.ISM
-@end example
-
-If you want to check all tables and repair all tables that are corrupted,
-you can use the following line:
-
-@example
-myisamchk --silent --force --fast --update-state -O key_buffer=64M -O sort_buffer=64M -O read_buffer=1M -O write_buffer=1M /path/to/datadir/*/*.MYI
-isamchk --silent --force -O key_buffer=64M -O sort_buffer=64M -O read_buffer=1M -O write_buffer=1M /path/to/datadir/*/*.ISM
-@end example
-
-The above assumes that you have more than 64 M free.
-
-Note that if you get an error like:
-
-@example
-myisamchk: warning: 1 clients is using or hasn't closed the table properly
-@end example
-
-This means that you are trying to check a table that has been updated by
-the another program (like the @code{mysqld} server) that hasn't yet closed
-the file or that has died without closing the file properly.
-
-If you @code{mysqld} is running, you must force a sync/close of all
-tables with @code{FLUSH TABLES} and ensure that no one is using the
-tables while you are running @code{myisamchk}. In @strong{MySQL} Version 3.23
-the easiest way to avoid this problem is to use @code{CHECK TABLE}
-instead of @code{myisamchk} to check tables.
-
-@menu
-* myisamchk general options::
-* myisamchk check options::
-* myisamchk repair options::
-* myisamchk other options::
-@end menu
-
-@cindex options, @code{myisamchk}
-@cindex @code{myisamchk}, options
-@node myisamchk general options, myisamchk check options, myisamchk syntax, myisamchk syntax
-@subsubsection General Options for @code{myisamchk}
-
-@code{myisamchk} supports the following options.
-
-@table @code
-@item -# or --debug=debug_options
-Output debug log. The @code{debug_options} string often is
-@code{'d:t:o,filename'}.
-@item -? or --help
-Display a help message and exit.
-@item -O var=option, --set-variable var=option
-Set the value of a variable. The possible variables and their default values
-for myisamchk can be examined with @code{myisamchk --help}:
-@multitable @columnfractions .3 .7
-@item key_buffer_size @tab 523264
-@item read_buffer_size @tab 262136
-@item write_buffer_size @tab 262136
-@item sort_buffer_size @tab 2097144
-@item sort_key_blocks @tab 16
-@item decode_bits @tab 9
-@end multitable
-
-@code{sort_buffer_size} is used when the keys are repaired by sorting
-keys, which is the normal case when you use @code{--recover}.
-
-@code{key_buffer_size} is used when you are checking the table with
-@code{--extended-check} or when the keys are repaired by inserting key
-row by row in to the table (like when doing normal inserts). Repairing
-through the key buffer is used in the following cases:
-
-@itemize @bullet
-@item
-If you use @code{--safe-recover}.
-@item
-If you are using a @code{FULLTEXT} index.
-@item
-If the temporary files needed to sort the keys would be more than twice
-as big as when creating the key file directly. This is often the case
-when you have big @code{CHAR}, @code{VARCHAR} or @code{TEXT} keys as the
-sort needs to store the whole keys during sorting. If you have lots
-of temporary space and you can force @code{myisamchk} to repair by sorting
-you can use the @code{--sort-recover} option.
-@end itemize
-
-Reparing through the key buffer takes much less disk space than using
-sorting, but is also much slower.
-
-If you want a faster repair, set the above variables to about 1/4 of your
-available memory. You can set both variables to big values, as only one
-of the above buffers will be used at a time.
-
-@item -s or --silent
-Silent mode. Write output only when errors occur. You can use @code{-s}
-twice (@code{-ss}) to make @code{myisamchk} very silent.
-@item -v or --verbose
-Verbose mode. Print more information. This can be used with @code{-d} and
-@code{-e}. Use @code{-v} multiple times (@code{-vv}, @code{-vvv}) for more
-verbosity!
-@item -V or --version
-Print the @code{myisamchk} version and exit.
-@item -w or, --wait
-Instead of giving an error if the table is locked, wait until the table
-is unlocked before continuing. Note that if you are running @code{mysqld}
-on the table with @code{--skip-locking}, the table can only be locked
-by another @code{myisamchk} command.
-@end table
-
-@cindex check options, myisamchk
-@cindex tables, checking
-@node myisamchk check options, myisamchk repair options, myisamchk general options, myisamchk syntax
-@subsubsection Check Options for @code{myisamchk}
-
-@table @code
-@item -c or --check
-Check table for errors. This is the default operation if you are not
-giving @code{myisamchk} any options that override this.
-
-@item -e or --extend-check
-Check the table VERY thoroughly (which is quite slow if you have many
-indexes). This option should only be used in extreme cases. Normally,
-@code{myisamchk} or @code{myisamchk --medium-check} should, in most
-cases, be able to find out if there are any errors in the table.
-
-If you are using @code{--extended-check} and have much memory, you should
-increase the value of @code{key_buffer_size} a lot!
-
-@item -F or --fast
-Check only tables that haven't been closed properly.
-@item -C or --check-only-changed
-Check only tables that have changed since the last check.
-@item -f or --force
-Restart @code{myisamchk} with @code{-r} (repair) on the table, if
-@code{myisamchk} finds any errors in the table.
-@item -i or --information
-Print informational statistics about the table that is checked.
-@item -m or --medium-check
-Faster than extended-check, but only finds 99.99% of all errors.
-Should, however, be good enough for most cases.
-@item -U or --update-state
-Store in the @file{.MYI} file when the table was checked and if the table crashed. This should be used to get full benefit of the
-@code{--check-only-changed} option, but you shouldn't use this
-option if the @code{mysqld} server is using the table and you are
-running @code{mysqld} with @code{--skip-locking}.
-@item -T or --read-only
-Don't mark table as checked. This is useful if you use @code{myisamchk}
-to check a table that is in use by some other application that doesn't
-use locking (like @code{mysqld --skip-locking}).
-@end table
-
-@cindex repair options, myisamchk
-@cindex files, repairing
-@node myisamchk repair options, myisamchk other options, myisamchk check options, myisamchk syntax
-@subsubsection Repair Options for myisamchk
-
-The following options are used if you start @code{myisamchk} with
-@code{-r} or @code{-o}:
-
-@table @code
-@item -D # or --data-file-length=#
-Max length of data file (when re-creating data file when it's 'full').
-@item -e or --extend-check
-Try to recover every possible row from the data file.
-Normally this will also find a lot of garbage rows. Don't use this option
-if you are not totally desperate.
-@item -f or --force
-Overwrite old temporary files (@code{table_name.TMD}) instead of aborting.
-@item -k # or keys-used=#
-If you are using ISAM, tells the ISAM table handler to update only the
-first @code{#} indexes. If you are using @code{MyISAM}, tells which keys
-to use, where each binary bit stands for one key (first key is bit 0).
-This can be used to get faster inserts! Deactivated indexes can be
-reactivated by using @code{myisamchk -r}. keys.
-@item -l or --no-symlinks
-Do not follow symbolic links. Normally @code{myisamchk} repairs the
-table a symlink points at. This option doesn't exist in MySQL 4.0,
-as MySQL 4.0 will not remove symlinks during repair.
-@item -r or --recover
-Can fix almost anything except unique keys that aren't unique
-(which is an extremely unlikely error with ISAM/MyISAM tables).
-If you want to recover a table, this is the option to try first. Only if
-myisamchk reports that the table can't be recovered by @code{-r}, you
-should then try @code{-o}. (Note that in the unlikely case that @code{-r}
-fails, the data file is still intact.)
-If you have lots of memory, you should increase the size of
-@code{sort_buffer_size}!
-@item -o or --safe-recover
-Uses an old recovery method (reads through all rows in order and updates
-all index trees based on the found rows); this is a magnitude slower
-than @code{-r}, but can handle a couple of very unlikely cases that
-@code{-r} cannot handle. This recovery method also uses much less disk
-space than @code{-r}. Normally one should always first repair with
-@code{-r}, and only if this fails use @code{-o}.
-
-If you have lots of memory, you should increase the size of
-@code{key_buffer_size}!
-@item -n or --sort-recover
-Force @code{myisamchk} to use sorting to resolve the keys even if the
-temporary files should be very big. This will not have any effect if you have
-fulltext keys in the table.
-@item --character-sets-dir=...
-Directory where character sets are stored.
-@item --set-character-set=name
-Change the character set used by the index
-@item .t or --tmpdir=path
-Path for storing temporary files. If this is not set, @code{myisamchk} will
-use the environment variable @code{TMPDIR} for this.
-@item -q or --quick
-Faster repair by not modifying the data file. One can give a second
-@code{-q} to force @code{myisamchk} to modify the original datafile in case
-of duplicate keys
-@item -u or --unpack
-Unpack file packed with myisampack.
-@end table
-
-@node myisamchk other options, , myisamchk repair options, myisamchk syntax
-@subsubsection Other Options for @code{myisamchk}
-
-Other actions that @code{myisamchk} can do, besides repair and check tables:
-@table @code
-@item -a or --analyze
-Analyze the distribution of keys. This improves join performance by
-enabling the join optimizer to better choose in which order it should
-join the tables and which keys it should use:
-@code{myisamchk --describe --verbose table_name'} or using @code{SHOW KEYS} in
-@strong{MySQL}.
-@item -d or --description
-Prints some information about table.
-@item -A or --set-auto-increment[=value]
-Force auto_increment to start at this or higher value. If no value is
-given, then sets the next auto_increment value to the highest used value
-for the auto key + 1.
-@item -S or --sort-index
-Sort the index tree blocks in high-low order.
-This will optimize seeks and will make table scanning by key faster.
-@item -R or --sort-records=#
-Sorts records according to an index. This makes your data much more localized
-and may speed up ranged @code{SELECT} and @code{ORDER BY} operations on
-this index. (It may be VERY slow to do a sort the first time!)
-To find out a table's index numbers, use @code{SHOW INDEX}, which shows a
-table's indexes in the same order that @code{myisamchk} sees them. Indexes are
-numbered beginning with 1.
-@end table
-
-@cindex memory usage, myisamchk
-@node myisamchk memory, , myisamchk syntax, Table maintenance
-@subsection @code{myisamchk} Memory Usage
-
-Memory allocation is important when you run @code{myisamchk}.
-@code{myisamchk} uses no more memory than you specify with the @code{-O}
-options. If you are going to use @code{myisamchk} on very large files,
-you should first decide how much memory you want it to use. The default
-is to use only about 3M to fix things. By using larger values, you can
-get @code{myisamchk} to operate faster. For example, if you have more
-than 32M RAM, you could use options such as these (in addition to any
-other options you might specify):
-
-@example
-shell> myisamchk -O sort=16M -O key=16M -O read=1M -O write=1M ...
-@end example
-
-Using @code{-O sort=16M} should probably be enough for most cases.
-
-Be aware that @code{myisamchk} uses temporary files in @code{TMPDIR}. If
-@code{TMPDIR} points to a memory file system, you may easily get out of
-memory errors. If this happens, set @code{TMPDIR} to point at some directory
-with more space and restart @code{myisamchk}.
-
-When repairing, @code{myisamchk} will also need a lot of disk space:
-
-@itemize @bullet
-@item
-Double the size of the record file (the original one and a copy). This
-space is not needed if one does a repair with @code{--quick}, as in this
-case only the index file will be re-created. This space is needed on the
-same disk as the original record file!
-@item
-Space for the new index file that replaces the old one. The old
-index file is truncated at start, so one usually ignore this space.
-This space is needed on the same disk as the original index file!
-@item
-When using @code{--recover} or @code{--sort-recover}
-(but not when using @code{--safe-recover}, you will need space for a
-sort buffer for:
-@code{(largest_key + row_pointer_length)*number_of_rows * 2}.
-You can check the length of the keys and the row_pointer_length with
-@code{myisamchk -dv table}.
-This space is allocated on the temporary disk (specified by @code{TMPDIR} or
-@code{--tmpdir=#}).
-@end itemize
-
-If you have a problem with disk space during repair, you can try to use
-@code{--safe-recover} instead of @code{--recover}.
-
-@node Using mysqlcheck, Maintenance regimen, Table maintenance, Maintenance
+@node Using mysqlcheck, , Maintenance, Maintenance
@section Using @code{mysqlcheck} for Table Maintenance and Crash Recovery
Since @strong{MySQL} version 3.23.38 you will be able to use a new
@@ -34596,780 +36729,7 @@ Print info about the various stages.
Output version information and exit.
@end table
-@cindex maintaining, tables
-@cindex tables, maintenance regimen
-@node Maintenance regimen, Table-info, Using mysqlcheck, Maintenance
-@section Setting Up a Table Maintenance Regimen
-
-Starting with @strong{MySQL} Version 3.23.13, you can check MyISAM
-tables with the @code{CHECK TABLE} command. @xref{CHECK TABLE}. You can
-repair tables with the @code{REPAIR TABLE} command. @xref{REPAIR TABLE}.
-
-It is a good idea to perform table checks on a regular basis rather than
-waiting for problems to occur. For maintenance purposes, you can use
-@code{myisamchk -s} to check tables. The @code{-s} option (short for
-@code{--silent}) causes @code{myisamchk} to run in silent mode, printing
-messages only when errors occur.
-
-@tindex .pid (process ID) file
-It's also a good idea to check tables when the server starts up.
-For example, whenever the machine has done a reboot in the middle of an
-update, you usually need to check all the tables that could have been
-affected. (This is an ``expected crashed table''.) You could add a test to
-@code{safe_mysqld} that runs @code{myisamchk} to check all tables that have
-been modified during the last 24 hours if there is an old @file{.pid}
-(process ID) file left after a reboot. (The @file{.pid} file is created by
-@code{mysqld} when it starts up and removed when it terminates normally. The
-presence of a @file{.pid} file at system startup time indicates that
-@code{mysqld} terminated abnormally.)
-
-An even better test would be to check any table whose last-modified time
-is more recent than that of the @file{.pid} file.
-
-You should also check your tables regularly during normal system
-operation. At @strong{MySQL AB}, we run a @code{cron} job to check all
-our important tables once a week, using a line like this in a @file{crontab}
-file:
-
-@example
-35 0 * * 0 /path/to/myisamchk --fast --silent /path/to/datadir/*/*.MYI
-@end example
-
-This prints out information about crashed tables so we can examine and repair
-them when needed.
-
-As we haven't had any unexpectedly crashed tables (tables that become
-corrupted for reasons other than hardware trouble)
-for a couple of years now (this is really true), once a week is
-more than enough for us.
-
-We recommend that to start with, you execute @code{myisamchk -s} each
-night on all tables that have been updated during the last 24 hours,
-until you come to trust @strong{MySQL} as much as we do.
-
-@cindex tables, defragment
-Normally you don't need to maintain @strong{MySQL} tables that much. If
-you are changing tables with dynamic size rows (tables with @code{VARCHAR},
-@code{BLOB} or @code{TEXT} columns) or have tables with many deleted rows
-you may want to from time to time (once a month?) defragment/reclaim space
-from the tables.
-
-You can do this by using @code{OPTIMIZE TABLE} on the tables in question or
-if you can take the @code{mysqld} server down for a while do:
-
-@example
-isamchk -r --silent --sort-index -O sort_buffer_size=16M */*.ISM
-myisamchk -r --silent --sort-index -O sort_buffer_size=16M */*.MYI
-@end example
-
-@cindex tables, information
-@node Table-info, Crash recovery, Maintenance regimen, Maintenance
-@section Getting Information About a Table
-
-To get a description of a table or statistics about it, use the commands shown
-below. We explain some of the information in more detail later:
-
-@table @code
-@item myisamchk -d tbl_name
-Runs @code{myisamchk} in ``describe mode'' to produce a description of
-your table. If you start the @strong{MySQL} server using the
-@code{--skip-locking} option, @code{myisamchk} may report an error for a
-table that is updated while it runs. However, because @code{myisamchk}
-doesn't change the table in describe mode, there isn't any risk of
-destroying data.
-
-@item myisamchk -d -v tbl_name
-To produce more information about what @code{myisamchk} is doing, add @code{-v}
-to tell it to run in verbose mode.
-
-@item myisamchk -eis tbl_name
-Shows only the most important information from a table. It is slow because it
-must read the whole table.
-
-@item myisamchk -eiv tbl_name
-This is like @code{-eis}, but tells you what is being done.
-@end table
-
-@cindex examples, @code{myisamchk} output
-@cindex @code{myisamchk}, example output
-Example of @code{myisamchk -d} output:
-@example
-MyISAM file: company.MYI
-Record format: Fixed length
-Data records: 1403698 Deleted blocks: 0
-Recordlength: 226
-
-table description:
-Key Start Len Index Type
-1 2 8 unique double
-2 15 10 multip. text packed stripped
-3 219 8 multip. double
-4 63 10 multip. text packed stripped
-5 167 2 multip. unsigned short
-6 177 4 multip. unsigned long
-7 155 4 multip. text
-8 138 4 multip. unsigned long
-9 177 4 multip. unsigned long
- 193 1 text
-@end example
-
-Example of @code{myisamchk -d -v} output:
-@example
-MyISAM file: company
-Record format: Fixed length
-File-version: 1
-Creation time: 1999-10-30 12:12:51
-Recover time: 1999-10-31 19:13:01
-Status: checked
-Data records: 1403698 Deleted blocks: 0
-Datafile parts: 1403698 Deleted data: 0
-Datafilepointer (bytes): 3 Keyfile pointer (bytes): 3
-Max datafile length: 3791650815 Max keyfile length: 4294967294
-Recordlength: 226
-
-table description:
-Key Start Len Index Type Rec/key Root Blocksize
-1 2 8 unique double 1 15845376 1024
-2 15 10 multip. text packed stripped 2 25062400 1024
-3 219 8 multip. double 73 40907776 1024
-4 63 10 multip. text packed stripped 5 48097280 1024
-5 167 2 multip. unsigned short 4840 55200768 1024
-6 177 4 multip. unsigned long 1346 65145856 1024
-7 155 4 multip. text 4995 75090944 1024
-8 138 4 multip. unsigned long 87 85036032 1024
-9 177 4 multip. unsigned long 178 96481280 1024
- 193 1 text
-@end example
-
-Example of @code{myisamchk -eis} output:
-@example
-Checking MyISAM file: company
-Key: 1: Keyblocks used: 97% Packed: 0% Max levels: 4
-Key: 2: Keyblocks used: 98% Packed: 50% Max levels: 4
-Key: 3: Keyblocks used: 97% Packed: 0% Max levels: 4
-Key: 4: Keyblocks used: 99% Packed: 60% Max levels: 3
-Key: 5: Keyblocks used: 99% Packed: 0% Max levels: 3
-Key: 6: Keyblocks used: 99% Packed: 0% Max levels: 3
-Key: 7: Keyblocks used: 99% Packed: 0% Max levels: 3
-Key: 8: Keyblocks used: 99% Packed: 0% Max levels: 3
-Key: 9: Keyblocks used: 98% Packed: 0% Max levels: 4
-Total: Keyblocks used: 98% Packed: 17%
-
-Records: 1403698 M.recordlength: 226 Packed: 0%
-Recordspace used: 100% Empty space: 0% Blocks/Record: 1.00
-Record blocks: 1403698 Delete blocks: 0
-Recorddata: 317235748 Deleted data: 0
-Lost space: 0 Linkdata: 0
-
-User time 1626.51, System time 232.36
-Maximum resident set size 0, Integral resident set size 0
-Non physical pagefaults 0, Physical pagefaults 627, Swaps 0
-Blocks in 0 out 0, Messages in 0 out 0, Signals 0
-Voluntary context switches 639, Involuntary context switches 28966
-@end example
-
-Example of @code{myisamchk -eiv} output:
-@example
-Checking MyISAM file: company
-Data records: 1403698 Deleted blocks: 0
-- check file-size
-- check delete-chain
-block_size 1024:
-index 1:
-index 2:
-index 3:
-index 4:
-index 5:
-index 6:
-index 7:
-index 8:
-index 9:
-No recordlinks
-- check index reference
-- check data record references index: 1
-Key: 1: Keyblocks used: 97% Packed: 0% Max levels: 4
-- check data record references index: 2
-Key: 2: Keyblocks used: 98% Packed: 50% Max levels: 4
-- check data record references index: 3
-Key: 3: Keyblocks used: 97% Packed: 0% Max levels: 4
-- check data record references index: 4
-Key: 4: Keyblocks used: 99% Packed: 60% Max levels: 3
-- check data record references index: 5
-Key: 5: Keyblocks used: 99% Packed: 0% Max levels: 3
-- check data record references index: 6
-Key: 6: Keyblocks used: 99% Packed: 0% Max levels: 3
-- check data record references index: 7
-Key: 7: Keyblocks used: 99% Packed: 0% Max levels: 3
-- check data record references index: 8
-Key: 8: Keyblocks used: 99% Packed: 0% Max levels: 3
-- check data record references index: 9
-Key: 9: Keyblocks used: 98% Packed: 0% Max levels: 4
-Total: Keyblocks used: 9% Packed: 17%
-
-- check records and index references
-[LOTS OF ROW NUMBERS DELETED]
-
-Records: 1403698 M.recordlength: 226 Packed: 0%
-Recordspace used: 100% Empty space: 0% Blocks/Record: 1.00
-Record blocks: 1403698 Delete blocks: 0
-Recorddata: 317235748 Deleted data: 0
-Lost space: 0 Linkdata: 0
-
-User time 1639.63, System time 251.61
-Maximum resident set size 0, Integral resident set size 0
-Non physical pagefaults 0, Physical pagefaults 10580, Swaps 0
-Blocks in 4 out 0, Messages in 0 out 0, Signals 0
-Voluntary context switches 10604, Involuntary context switches 122798
-@end example
-
-Here are the sizes of the data and index files for the table used in the
-preceding examples:
-
-@example
--rw-rw-r-- 1 monty tcx 317235748 Jan 12 17:30 company.MYD
--rw-rw-r-- 1 davida tcx 96482304 Jan 12 18:35 company.MYM
-@end example
-
-Explanations for the types of information @code{myisamchk} produces are
-given below. The ``keyfile'' is the index file. ``Record'' and ``row''
-are synonymous:
-
-@table @code
-@item ISAM file
-Name of the ISAM (index) file.
-
-@item Isam-version
-Version of ISAM format. Currently always 2.
-
-@item Creation time
-When the data file was created.
-
-@item Recover time
-When the index/data file was last reconstructed.
-
-@item Data records
-How many records are in the table.
-
-@item Deleted blocks
-How many deleted blocks still have reserved space.
-You can optimize your table to minimize this space.
-@xref{Optimization}.
-
-@item Datafile: Parts
-For dynamic record format, this indicates how many data blocks there are. For
-an optimized table without fragmented records, this is the same as @code{Data
-records}.
-
-@item Deleted data
-How many bytes of non-reclaimed deleted data there are.
-You can optimize your table to minimize this space.
-@xref{Optimization}.
-
-@item Datafile pointer
-The size of the data file pointer, in bytes. It is usually 2, 3, 4, or 5
-bytes. Most tables manage with 2 bytes, but this cannot be controlled
-from @strong{MySQL} yet. For fixed tables, this is a record address. For
-dynamic tables, this is a byte address.
-
-@item Keyfile pointer
-The size of the index file pointer, in bytes. It is usually 1, 2, or 3
-bytes. Most tables manage with 2 bytes, but this is calculated
-automatically by @strong{MySQL}. It is always a block address.
-
-@item Max datafile length
-How long the table's data file (@code{.MYD} file) can become, in bytes.
-
-@item Max keyfile length
-How long the table's key file (@code{.MYI} file) can become, in bytes.
-
-@item Recordlength
-How much space each record takes, in bytes.
-
-@item Record format
-The format used to store table rows.
-The examples shown above use @code{Fixed length}.
-Other possible values are @code{Compressed} and @code{Packed}.
-
-@item table description
-A list of all keys in the table. For each key, some low-level information
-is presented:
-
-@table @code
-@item Key
-This key's number.
-
-@item Start
-Where in the record this index part starts.
-
-@item Len
-How long this index part is. For packed numbers, this should always be
-the full length of the column. For strings, it may be shorter than the full
-length of the indexed column, because you can index a prefix of a string
-column.
-
-@item Index
-@code{unique} or @code{multip.} (multiple). Indicates whether or not one value
-can exist multiple times in this index.
-
-@item Type
-What data-type this index part has. This is an ISAM data-type
-with the options @code{packed}, @code{stripped} or @code{empty}.
-
-@item Root
-Address of the root index block.
-
-@item Blocksize
-The size of each index block. By default this is 1024, but the value may be
-changed at compile time.
-
-@item Rec/key
-This is a statistical value used by the optimizer. It tells how many
-records there are per value for this key. A unique key always has a
-value of 1. This may be updated after a table is loaded (or greatly
-changed) with @code{myisamchk -a}. If this is not updated at all, a default
-value of 30 is given.
-@end table
-
-@item
-In the first example above, the 9th key is a multi-part key with two parts.
-
-@item Keyblocks used
-What percentage of the keyblocks are used. Because the table used in the
-examples had just been reorganized with @code{myisamchk}, the values are very
-high (very near the theoretical maximum).
-
-@item Packed
-@strong{MySQL} tries to pack keys with a common suffix. This can only be used
-for @code{CHAR}/@code{VARCHAR}/@code{DECIMAL} keys. For long strings like
-names, this can significantly reduce the space used. In the third example
-above, the 4th key is 10 characters long and a 60% reduction in space is
-achieved.
-
-@item Max levels
-How deep the B-tree for this key is. Large tables with long keys get high
-values.
-
-@item Records
-How many rows are in the table.
-
-@item M.recordlength
-The average record length. For tables with fixed-length records, this is the
-exact record length.
-
-@item Packed
-@strong{MySQL} strips spaces from the end of strings. The @code{Packed}
-value indicates the percentage of savings achieved by doing this.
-
-@item Recordspace used
-What percentage of the data file is used.
-
-@item Empty space
-What percentage of the data file is unused.
-
-@item Blocks/Record
-Average number of blocks per record (that is, how many links a fragmented
-record is composed of). This is always 1 for fixed-format tables. This value
-should stay as close to 1.0 as possible. If it gets too big, you can
-reorganize the table with @code{myisamchk}.
-@xref{Optimization}.
-
-@item Recordblocks
-How many blocks (links) are used. For fixed format, this is the same as the number
-of records.
-
-@item Deleteblocks
-How many blocks (links) are deleted.
-
-@item Recorddata
-How many bytes in the data file are used.
-
-@item Deleted data
-How many bytes in the data file are deleted (unused).
-
-@item Lost space
-If a record is updated to a shorter length, some space is lost. This is
-the sum of all such losses, in bytes.
-
-@item Linkdata
-When the dynamic table format is used, record fragments are linked with
-pointers (4 to 7 bytes each). @code{Linkdata} is the sum of the amount of
-storage used by all such pointers.
-@end table
-
-If a table has been compressed with @code{myisampack}, @code{myisamchk
--d} prints additional information about each table column. See
-@ref{myisampack, , @code{myisampack}}, for an example of this
-information and a description of what it means.
-
-@cindex crash, recovery
-@cindex recovery, from crash
-@node Crash recovery, Log file maintenance, Table-info, Maintenance
-@section Using @code{myisamchk} for Crash Recovery
-
-If you run @code{mysqld} with @code{--skip-locking} (which is the default on
-some systems, like Linux), you can't reliably use @code{myisamchk} to
-check a table when @code{mysqld} is using the same table. If you
-can be sure that no one is accessing the tables through @code{mysqld}
-while you run @code{myisamchk}, you only have to do @code{mysqladmin
-flush-tables} before you start checking the tables. If you can't
-guarantee the above, then you must take down @code{mysqld} while you
-check the tables. If you run @code{myisamchk} while @code{mysqld} is updating
-the tables, you may get a warning that a table is corrupt even if it
-isn't.
-
-If you are not using @code{--skip-locking}, you can use @code{myisamchk}
-to check tables at any time. While you do this, all clients that try
-to update the table will wait until @code{myisamchk} is ready before
-continuing.
-
-If you use @code{myisamchk} to repair or optimize tables, you
-@strong{MUST} always ensure that the @code{mysqld} server is not using
-the table (this also applies if you are using @code{--skip-locking}).
-If you don't take down @code{mysqld} you should at least do a
-@code{mysqladmin flush-tables} before you run @code{myisamchk}.
-
-This chapter describes how to check for and deal with data corruption
-in @strong{MySQL} databases. If your tables get corrupted a lot you should
-try to find the reason for this! @xref{Crashing}.
-
-The @code{MyISAM} table section contains reason for why a table could be
-corrupted. @xref{MyISAM table problems}.
-
-When performing crash recovery, it is important to understand that each table
-@code{tbl_name} in a database corresponds to three files in the database
-directory:
-
-@multitable @columnfractions .2 .8
-@item @strong{File} @tab @strong{Purpose}
-@item @file{tbl_name.frm} @tab Table definition (form) file
-@item @file{tbl_name.MYD} @tab Data file
-@item @file{tbl_name.MYI} @tab Index file
-@end multitable
-
-Each of these three file types is subject to corruption in various ways, but
-problems occur most often in data files and index files.
-
-@code{myisamchk} works by creating a copy of the @file{.MYD} (data) file
-row by row. It ends the repair stage by removing the old @file{.MYD}
-file and renaming the new file to the original file name. If you use
-@code{--quick}, @code{myisamchk} does not create a temporary @file{.MYD}
-file, but instead assumes that the @file{.MYD} file is correct and only
-generates a new index file without touching the @file{.MYD} file. This
-is safe, because @code{myisamchk} automatically detects if the
-@file{.MYD} file is corrupt and aborts the repair in this case. You can
-also give two @code{--quick} options to @code{myisamchk}. In this case,
-@code{myisamchk} does not abort on some errors (like duplicate key) but
-instead tries to resolve them by modifying the @file{.MYD}
-file. Normally the use of two @code{--quick} options is useful only if
-you have too little free disk space to perform a normal repair. In this
-case you should at least make a backup before running @code{myisamchk}.
-
-@menu
-* Check:: How to check tables for errors
-* Repair:: How to repair tables
-* Optimization:: Table optimization
-@end menu
-
-@cindex checking, tables for errors
-@cindex tables, error checking
-@cindex errors, checking tables for
-@node Check, Repair, Crash recovery, Crash recovery
-@subsection How to Check Tables for Errors
-
-To check a MyISAM table, use the following commands:
-
-@table @code
-@item myisamchk tbl_name
-This finds 99.99% of all errors. What it can't find is corruption that
-involves @strong{ONLY} the data file (which is very unusual). If you want
-to check a table, you should normally run @code{myisamchk} without options or
-with either the @code{-s} or @code{--silent} option.
-
-@item myisamchk -m tbl_name
-This finds 99.999% of all errors. It checks first all index entries for errors and
-then it reads through all rows. It calculates a checksum for all keys in
-the rows and verifies that they checksum matches the checksum for the keys
-in the index tree.
-
-@item myisamchk -e tbl_name
-This does a complete and thorough check of all data (@code{-e} means
-``extended check''). It does a check-read of every key for each row to verify
-that they indeed point to the correct row. This may take a LONG time on a
-big table with many keys. @code{myisamchk} will normally stop after the first
-error it finds. If you want to obtain more information, you can add the
-@code{--verbose} (@code{-v}) option. This causes @code{myisamchk} to keep
-going, up through a maximum of 20 errors. In normal usage, a simple
-@code{myisamchk} (with no arguments other than the table name) is sufficient.
-
-@item myisamchk -e -i tbl_name
-Like the previous command, but the @code{-i} option tells @code{myisamchk} to
-print some informational statistics, too.
-@end table
-
-@cindex tables, repairing
-@cindex repairing, tables
-@node Repair, Optimization, Check, Crash recovery
-@subsection How to Repair Tables
-
-In the following section we only talk about using @code{myisamchk} on
-@code{MyISAM} tables (extensions @code{.MYI} and @code{.MYD}). If you
-are using @code{ISAM} tables (extensions @code{.ISM} and @code{.ISD}),
-you should use @code{isamchk} instead.
-
-Starting with @strong{MySQL} Version 3.23.14, you can repair MyISAM
-tables with the @code{REPAIR TABLE} command. @xref{REPAIR TABLE}.
-
-The symptoms of a corrupted table include queries that abort unexpectedly
-and observable errors such as these:
-
-@itemize @bullet
-@item
-@file{tbl_name.frm} is locked against change
-@item
-Can't find file @file{tbl_name.MYI} (Errcode: ###)
-@item
-Unexpected end of file
-@item
-Record file is crashed
-@item
-Got error ### from table handler
-
-To get more information about the error you can run @code{perror ###}. Here
-is the most common errors that indicates a problem with the table:
-
-@example
-shell> perror 126 127 132 134 135 136 141 144 145
-126 = Index file is crashed / Wrong file format
-127 = Record-file is crashed
-132 = Old database file
-134 = Record was already deleted (or record file crashed)
-135 = No more room in record file
-136 = No more room in index file
-141 = Duplicate unique key or constraint on write or update
-144 = Table is crashed and last repair failed
-145 = Table was marked as crashed and should be repaired
-@end example
-
-Note that error 135, no more room in record file, is not an error that
-can be fixed by a simple repair. In this case you have to do:
-
-@example
-ALTER TABLE table MAX_ROWS=xxx AVG_ROW_LENGTH=yyy;
-@end example
-
-@end itemize
-
-In the other cases, you must repair your tables. @code{myisamchk}
-can usually detect and fix most things that go wrong.
-
-The repair process involves up to four stages, described below. Before you
-begin, you should @code{cd} to the database directory and check the
-permissions of the table files. Make sure they are readable by the Unix user
-that @code{mysqld} runs as (and to you, because you need to access the files
-you are checking). If it turns out you need to modify files, they must also
-be writable by you.
-
-If you are using @strong{MySQL} Version 3.23.16 and above, you can (and
-should) use the @code{CHECK} and @code{REPAIR} commands to check and repair
-@code{MyISAM} tables. @xref{CHECK TABLE}. @xref{REPAIR TABLE}.
-
-The manual section about table maintenance includes the options to
-@code{isamchk}/@code{myisamchk}. @xref{Table maintenance}.
-
-The following section is for the cases where the above command fails or
-if you want to use the extended features that @code{isamchk}/@code{myisamchk} provides.
-
-If you are going to repair a table from the command line, you must first
-take down the @code{mysqld} server. Note that when you do
-@code{mysqladmin shutdown} on a remote server, the @code{mysqld} server
-will still be alive for a while after @code{mysqladmin} returns, until
-all queries are stopped and all keys have been flushed to disk.
-
-@noindent
-@strong{Stage 1: Checking your tables}
-
-Run @code{myisamchk *.MYI} or @code{myisamchk -e *.MYI} if you have
-more time. Use the @code{-s} (silent) option to suppress unnecessary
-information.
-
-If the @code{mysqld} server is done you should use the --update option to tell
-@code{myisamchk} to mark the table as 'checked'.
-
-You have to repair only those tables for which @code{myisamchk} announces an
-error. For such tables, proceed to Stage 2.
-
-If you get weird errors when checking (such as @code{out of
-memory} errors), or if @code{myisamchk} crashes, go to Stage 3.
-
-@noindent
-@strong{Stage 2: Easy safe repair}
-
-NOTE: If you want repairing to go much faster, you should add: @code{-O
-sort_buffer=# -O key_buffer=#} (where # is about 1/4 of the available
-memory) to all @code{isamchk/myisamchk} commands.
-
-First, try @code{myisamchk -r -q tbl_name} (@code{-r -q} means ``quick
-recovery mode''). This will attempt to repair the index file without
-touching the data file. If the data file contains everything that it
-should and the delete links point at the correct locations within the
-data file, this should work, and the table is fixed. Start repairing the
-next table. Otherwise, use the following procedure:
-
-@enumerate
-@item
-Make a backup of the data file before continuing.
-
-@item
-Use @code{myisamchk -r tbl_name} (@code{-r} means ``recovery mode''). This will
-remove incorrect records and deleted records from the data file and
-reconstruct the index file.
-
-@item
-If the preceding step fails, use @code{myisamchk --safe-recover tbl_name}.
-Safe recovery mode uses an old recovery method that handles a few cases that
-regular recovery mode doesn't (but is slower).
-@end enumerate
-
-If you get weird errors when repairing (such as @code{out of
-memory} errors), or if @code{myisamchk} crashes, go to Stage 3.
-
-@noindent
-@strong{Stage 3: Difficult repair}
-
-You should only reach this stage if the first 16K block in the index file is
-destroyed or contains incorrect information, or if the index file is
-missing. In this case, it's necessary to create a new index file. Do so as
-follows:
-
-@enumerate
-@item
-Move the data file to some safe place.
-
-@item
-Use the table description file to create new (empty) data and index files:
-
-@example
-shell> mysql db_name
-mysql> SET AUTOCOMMIT=1;
-mysql> TRUNCATE TABLE table_name;
-mysql> quit
-@end example
-
-If your SQL version doesn't have @code{TRUNCATE TABLE}, use @code{DELETE FROM
-table_name} instead.
-
-@item
-Copy the old data file back onto the newly created data file.
-(Don't just move the old file back onto the new file; you want to retain
-a copy in case something goes wrong.)
-@end enumerate
-
-Go back to Stage 2. @code{myisamchk -r -q} should work now. (This shouldn't
-be an endless loop.)
-
-@noindent
-@strong{Stage 4: Very difficult repair}
-
-You should reach this stage only if the description file has also
-crashed. That should never happen, because the description file isn't changed
-after the table is created:
-
-@enumerate
-@item
-Restore the description file from a backup and go back to Stage 3. You can
-also restore the index file and go back to Stage 2. In the latter case, you
-should start with @code{myisamchk -r}.
-
-@item
-If you don't have a backup but know exactly how the table was created, create
-a copy of the table in another database. Remove the new data file, then move
-the description and index files from the other database to your crashed
-database. This gives you new description and index files, but leaves
-the data file alone. Go back to Stage 2 and attempt to reconstruct
-the index file.
-@end enumerate
-
-@cindex tables, optimizing
-@cindex optimizing, tables
-@node Optimization, , Repair, Crash recovery
-@subsection Table Optimization
-
-To coalesce fragmented records and eliminate wasted space resulting from
-deleting or updating records, run @code{myisamchk} in recovery mode:
-
-@example
-shell> myisamchk -r tbl_name
-@end example
-
-You can optimize a table in the same way using the SQL @code{OPTIMIZE TABLE}
-statement. @code{OPTIMIZE TABLE} does a repair of the table, a key
-analyzes and also sorts the index tree to give faster key lookups.
-There is also no possibility of unwanted interaction between a utility
-and the server, because the server does all the work when you use
-@code{OPTIMIZE TABLE}. @xref{OPTIMIZE TABLE}.
-
-@code{myisamchk} also has a number of other options you can use to improve
-the performance of a table:
-
-@table @code
-@item -S, --sort-index
-@item -R index_num, --sort-records=index_num
-@item -a, --analyze
-@end table
-
-For a full description of the option. @xref{myisamchk syntax}.
-
-@cindex files, log
-@cindex maintaining, log files
-@cindex log files, maintaining
-@node Log file maintenance, , Crash recovery, Maintenance
-@section Log file Maintenance
-
-@strong{MySQL} has a lot of log files which make it easy to see what is
-going. @xref{Log files}. One must however from time to time clean up
-after @code{MysQL} to ensure that the logs don't take up too much disk
-space.
-
-When using @strong{MySQL} with log files, you will, from time to time,
-want to remove/backup old log files and tell @strong{MySQL} to start
-logging on new files. @xref{Backup}.
-
-On a Linux (@code{Redhat}) installation, you can use the
-@code{mysql-log-rotate} script for this. If you installed @strong{MySQL}
-from an RPM distribution, the script should have been installed
-automatically. Note that you should be careful with this if you are using
-the log for replication!
-
-On other systems you must install a short script yourself that you
-start from @code{cron} to handle log files.
-
-You can force @strong{MySQL} to start using new log files by using
-@code{mysqladmin flush-logs} or by using the SQL command @code{FLUSH LOGS}.
-If you are using @strong{MySQL} Version 3.21 you must use @code{mysqladmin refresh}.
-
-The above command does the following:
-
-@itemize @bullet
-@item
-If standard logging (@code{--log}) or slow query logging
-(@code{--log-slow-queries}) is used, closes and reopens the log file.
-(@file{mysql.log} and @file{`hostname`-slow.log} as default).
-@item
-If update logging (@code{--log-update}) is used, closes the update log and
-opens a new log file with a higher sequence number.
-@end itemize
-
-If you are using only an update log, you only have to flush the logs and then
-move away the old update log files to a backup.
-If you are using the normal logging, you can do something like:
-
-@example
-shell> cd mysql-data-directory
-shell> mv mysql.log mysql.old
-shell> mysqladmin flush-logs
-@end example
-and then take a backup and remove @file{mysql.old}.
@cindex functions, new
@cindex adding, new functions
@@ -36683,7 +38043,6 @@ pre-allocated MYSQL struct.
* Link errors:: Problems when linking with the @strong{MySQL} client library
* Common errors:: Some common errors when using @strong{MySQL}
* Full disk:: How @strong{MySQL} handles a full disk
-* Multiple sql commands:: How to run SQL commands from a text file
* Temporary files:: Where @strong{MySQL} stores temporary files
* Problems with mysql.sock:: How to protect @file{/tmp/mysql.sock}
* Changing MySQL user:: How to run @strong{MySQL} as a normal user
@@ -37605,7 +38964,7 @@ to be.
@cindex full disk
@cindex disk full
-@node Full disk, Multiple sql commands, Common errors, Problems
+@node Full disk, Temporary files, Common errors, Problems
@section How MySQL Handles a Full Disk
@noindent
@@ -37648,35 +39007,8 @@ it will remove the big temporary files and mark the table as crashed
(except for @code{ALTER TABLE}, in which the old table will be left
unchanged).
-@node Multiple sql commands, Temporary files, Full disk, Problems
-@section How to Run SQL Commands from a Text File
-
-The @code{mysql} client typically is used interactively, like this:
-
-@example
-shell> mysql database
-@end example
-
-However, it's also possible to put your SQL commands in a file and tell
-@code{mysql} to read its input from that file. To do so, create a text
-file @file{text_file} that contains the commands you wish to execute.
-Then invoke @code{mysql} as shown below:
-
-@example
-shell> mysql database < text_file
-@end example
-
-You can also start your text file with a @code{USE db_name} statement. In
-this case, it is unnecessary to specify the database name on the command
-line:
-
-@example
-shell> mysql < text_file
-@end example
-
-@xref{Programs}.
-@node Temporary files, Problems with mysql.sock, Multiple sql commands, Problems
+@node Temporary files, Problems with mysql.sock, Full disk, Problems
@section Where MySQL Stores Temporary Files
@strong{MySQL} uses the value of the @code{TMPDIR} environment variable as
@@ -38345,14 +39677,12 @@ We plan to fix the above in 4.0.
@cindex problems, solving
@cindex solving, problems
@cindex databases, replicating
-@node Common problems, Log files, Problems, Top
+@node Common problems, Clients, Problems, Top
@chapter Solving Some Common Problems with MySQL
@cindex replication
@menu
* Log Replication:: Database replication with update log
-* Backup:: Database backups
-* Multiple servers:: Running multiple @strong{MySQL} servers on the same machine
@end menu
In this chapter, you will find information to solve some of the more common
@@ -38362,7 +39692,7 @@ database using the update or binary logs.
@cindex database replication
@cindex replication, database
-@node Log Replication, Backup, Common problems, Common problems
+@node Log Replication, , Common problems, Common problems
@section Database Replication with Update Log
Now that master-slave internal replication is available starting in
@@ -38404,491 +39734,15 @@ not return the same value as in the original database:
All time functions are safe to use, as the timestamp is sent to the
mirror if needed. @code{LAST_INSERT_ID()} is also safe to use.
-@cindex databases, backups
-@cindex backups
-@node Backup, Multiple servers, Log Replication, Common problems
-@section Database Backups
-
-Because @strong{MySQL} tables are stored as files, it is easy to do a
-backup. To get a consistent backup, do a @code{LOCK TABLES} on the
-relevant tables followed by @code{FLUSH TABLES} for the tables.
-@xref{LOCK TABLES, , @code{LOCK TABLES}}.
-@xref{FLUSH, , @code{FLUSH}}.
-You only need a read lock; this allows other threads to continue to
-query the tables while you are making a copy of the files in the
-database directory. The @code{FLUSH TABLE} is needed to ensure that
-the all active index pages is written to disk before you start the backup.
-
-If you want to make a SQL level backup of a table, you can use
-@code{SELECT INTO OUTFILE} or @code{BACKUP TABLE}. @xref{SELECT}.
-@xref{BACKUP TABLE}.
-
-Another way to back up a database is to use the @code{mysqldump} program or
-the @code{mysqlhotcopy script}. @xref{mysqldump, , @code{mysqldump}}.
-@xref{mysqlhotcopy, , @code{mysqlhotcopy}}.
-
-@enumerate
-@item
-Do a full backup of your databases:
-
-@example
-shell> mysqldump --tab=/path/to/some/dir --opt --full
-or
-
-shell> mysqlhotcopy database /path/to/some/dir
-@end example
-
-You can also simply copy all table files (@file{*.frm}, @file{*.MYD}, and
-@file{*.MYI} files) as long as the server isn't updating anything.
-The script @code{mysqlhotcopy} does use this method.
-
-@item
-@cindex log files, names
-Stop @code{mysqld} if it's running, then start it with the
-@code{--log-update[=file_name]} option. @xref{Update log}. The update
-log file(s) provide you with the information you need to replicate
-changes to the database that are made subsequent to the point at which
-you executed @code{mysqldump}.
-@end enumerate
-
-If you have to restore something, try to recover your tables using
-@code{REPAIR TABLE} or @code{myisamchk -r} first. That should work in
-99.9% of all cases. If @code{myisamchk} fails, try the following
-procedure: (This will only work if you have started @strong{MySQL} with
-@code{--log-update}. @xref{Update log}.):
-
-@enumerate
-@item
-Restore the original @code{mysqldump} backup.
-@item
-Execute the following command to re-run the updates in the binary log:
-
-@example
-shell> mysqlbinlog hostname-bin.[0-9]* | mysql
-@end example
-
-If you are using the update log you can use:
-
-@example
-shell> ls -1 -t -r hostname.[0-9]* | xargs cat | mysql
-@end example
-@end enumerate
-
-@code{ls} is used to get all the update log files in the right order.
-
-You can also do selective backups with @code{SELECT * INTO OUTFILE 'file_name'
-FROM tbl_name} and restore with @code{LOAD DATA INFILE 'file_name' REPLACE
-...} To avoid duplicate records, you need a @code{PRIMARY KEY} or a
-@code{UNIQUE} key in the table. The @code{REPLACE} keyword causes old records
-to be replaced with new ones when a new record duplicates an old record on
-a unique key value.
-
-If you get performance problems in making backups on your system, you can
-solve this by setting up replication and do the backups on the slave
-instead of on the master. @xref{Replication Intro}.
-
-If you are using a Veritas file system, you can do:
-
-@enumerate
-@item
-Execute in a client (perl ?) @code{FLUSH TABLES WITH READ LOCK}
-@item
-Fork a shell or execute in another client @code{mount vxfs snapshot}.
-@item
-Execute in the first client @code{UNLOCK TABLES}
-@item
-Copy files from snapshot
-@item
-Unmount snapshot
-@end enumerate
-
-@cindex multiple servers
-@cindex servers, multiple
-@cindex running, multiple servers
-@node Multiple servers, , Backup, Common problems
-@section Running Multiple MySQL Servers on the Same Machine
-
-There are circumstances when you might want to run multiple servers on the same
-machine. For example, you might want to test a new @strong{MySQL} release
-while leaving your existing production setup undisturbed. Or you might
-be an Internet service provider that wants to provide independent
-@strong{MySQL} installations for different customers.
-
-If you want to run multiple servers, the easiest way is to compile the servers
-with different TCP/IP ports and socket files so they are not
-both listening to the same TCP/IP port or socket file. @xref{mysqld_multi, ,
-@code{mysqld_multi}}.
-
-Assume an existing server is configured for the default port number and
-socket file. Then configure the new server with a @code{configure} command
-something like this:
-
-@example
-shell> ./configure --with-tcp-port=port_number \
- --with-unix-socket-path=file_name \
- --prefix=/usr/local/mysql-3.22.9
-@end example
-
-Here @code{port_number} and @code{file_name} should be different than the
-default port number and socket file pathname, and the @code{--prefix} value
-should specify an installation directory different than the one under which
-the existing @strong{MySQL} installation is located.
-
-You can check the socket used by any currently executing @strong{MySQL} server
-with this command:
-
-@example
-shell> mysqladmin -h hostname --port=port_number variables
-@end example
-
-Note that if you specify ``@code{localhost}'' as a hostname, @code{mysqladmin}
-will default to using Unix sockets instead of TCP/IP.
-
-If you have a @strong{MySQL} server running on the port you used, you will
-get a list of some of the most important configurable variables in
-@strong{MySQL}, including the socket name.
-
-You don't have to recompile a new @strong{MySQL} server just to start with
-a different port and socket. You can change the port and socket to be used
-by specifying them at run time as options to @code{safe_mysqld}:
-
-@example
-shell> /path/to/safe_mysqld --socket=file_name --port=port_number
-@end example
-
-@code{mysqld_multi} can also take @code{safe_mysqld} (or @code{mysqld})
-as an argument and pass the options from a configuration file to
-@code{safe_mysqld} and further to @code{mysqld}.
-
-If you run the new server on the same database directory as another
-server with logging enabled, you should also specify the name of the log
-files to @code{safe_mysqld} with @code{--log}, @code{--log-update}, or
-@code{--log-slow-queries}. Otherwise, both servers may be trying to
-write to the same log file.
-
-@strong{WARNING}: Normally you should never have two servers that update
-data in the same database! If your OS doesn't support fault-free system
-locking, this may lead to unpleasant surprises!
-
-If you want to use another database directory for the second server, you
-can use the @code{--datadir=path} option to @code{safe_mysqld}.
-
-@strong{NOTE} also that starting several @strong{MySQL} servers
-(@code{mysqlds}) in different machines and letting them access one data
-directory over @code{NFS} is generally a @strong{BAD IDEA}! The problem
-is that the @code{NFS} will become the bottleneck with the speed. It is
-not meant for such use. And last but not least, you would still have to
-come up with a solution how to make sure that two or more @code{mysqlds}
-are not interfering with each other. At the moment there is no platform
-that would 100% reliable do the file locking (@code{lockd} daemon
-usually) in every situation. Yet there would be one more possible risk
-with @code{NFS}; it would make the work even more complicated for
-@code{lockd} daemon to handle. So make it easy for your self and forget
-about the idea. The working solution is to have one computer with an
-operating system that efficiently handles threads and have several CPUs
-in it.
-
-When you want to connect to a @strong{MySQL} server that is running with
-a different port than the port that is compiled into your client, you
-can use one of the following methods:
-
-@itemize @bullet
-@item
-Start the client with @code{--host 'hostname' --port=port_number} to connect
-with TCP/IP, or @code{[--host localhost] --socket=file_name} to connect via
-a Unix socket.
-
-@item
-In your C or Perl programs, you can give the port or socket arguments
-when connecting to the @strong{MySQL} server.
-
-@item
-If your are using the Perl @code{DBD::mysql} module you can read the options
-from the @strong{MySQL} option files. @xref{Option files}.
-
-@example
-$dsn = "DBI:mysql:test;mysql_read_default_group=client;mysql_read_default_file=/usr/local/mysql/data/my.cnf"
-$dbh = DBI->connect($dsn, $user, $password);
-@end example
-
-@item
-@tindex MYSQL_UNIX_PORT environment variable
-@tindex MYSQL_TCP_PORT environment variable
-@tindex environment variable, MYSQL_UNIX_PORT
-@tindex environment variable, MYSQL_TCP_PORT
-Set the @code{MYSQL_UNIX_PORT} and @code{MYSQL_TCP_PORT} environment variables
-to point to the Unix socket and TCP/IP port before you start your clients.
-If you normally use a specific socket or port, you should place commands
-to set these environment variables in your @file{.login} file.
-@xref{Environment variables}. @xref{Programs}.
-
-@item
-@tindex .my.cnf file
-Specify the default socket and TCP/IP port in the @file{.my.cnf} file in your
-home directory. @xref{Option files}.
-@end itemize
-
-@cindex Log files
-@node Log files, Clients, Common problems, Top
-@chapter The MySQL log files
-
-@strong{MySQL} has several different log files that can help you find
-out what's going on inside @code{mysqld}:
-
-@multitable @columnfractions .3 .7
-@item The error log @tab Problems encountering starting, running or stopping @code{mysqld}.
-@item The isam log @tab Logs all changes to the ISAM tables. Used only for debugging the isam code.
-@item The query log @tab Established connections and executed queries.
-@item The update log @tab Deprecated: Stores all statements that changes data
-@item The binary log @tab Stores all statements that changes something. Used also for replication
-@item The slow log @tab Stores all queries that took more than @code{long_query_time} to execute or didn't use indexes.
-@end multitable
-
-All logs can be found in the @code{mysqld} data directory. You can
-force @code{mysqld} to reopen the log files (or in some cases
-switch to a new log) by executing @code{FLUSH LOGS}. @xref{FLUSH}.
-
-@cindex error log
-@cindex files, error log
-@menu
-* Error log::
-* Query log::
-* Update log::
-* Binary log::
-* Slow query log::
-@end menu
-
-@node Error log, Query log, Log files, Log files
-@section The Error Log
-
-@code{mysqld} writes all errors to the stderr, which the
-@code{safe_mysqld} script redirects to a file called
-@code{'hostname'.err}. (On Windows, @code{mysqld} writes this directly
-to @file{\mysql\data\mysql.err}).
-
-This contains information indicating when @code{mysqld} was started and
-stopped and also any critical errors found when running. If @code{mysqld}
-dies unexpectedly and @code{safe_mysqld} needs to restart @code{mysqld},
-@code{safe_mysqld} will write a @code{restarted mysqld} row in this
-file. This log also holds a warning if @code{mysqld} notices a table
-that needs to be automatically checked or repaired.
-
-On some operating systems, the error log will contain a stack trace
-for where @code{mysqld} died. This can be used to find out where
-@code{mysqld} died. @xref{Using stack trace}.
-
-@cindex query log
-@cindex files, query log
-@node Query log, Update log, Error log, Log files
-@section The Query Log
-
-If you want to know what happens within @code{mysqld}, you should start
-it with @code{--log[=file]}. This will log all connections and queries
-to the log file (by default named @file{'hostname'.log}). This log can
-be very useful when you suspect an error in a client and want to know
-exactly what @code{mysqld} thought the client sent to it.
-
-By default, the @code{mysql.server} script starts the @strong{MySQL}
-server with the @code{-l} option. If you need better performance when
-you start using @strong{MySQL} in a production environment, you can
-remove the @code{-l} option from @code{mysql.server} or change it to
-@code{--log-binary}.
-
-The entries in this log are written as @code{mysqld} receives the questions.
-This may be different than the order in which the statements are executed.
-This is in contrast to the update log and the binary log which are written
-after the query is executed, but before any locks are released.
-
-@cindex update log
-@cindex files, update log
-@node Update log, Binary log, Query log, Log files
-@section The Update Log
-
-@strong{NOTE}: The update log is replaced by the binary
-log. @xref{Binary log}. With this you can do anything that you can do
-with the update log.
-
-When started with the @code{--log-update[=file_name]} option,
-@code{mysqld} writes a log file containing all SQL commands that update
-data. If no filename is given, it defaults to the name of the host
-machine. If a filename is given, but it doesn't contain a path, the file
-is written in the data directory. If @file{file_name} doesn't have an
-extension, @code{mysqld} will create log file names like so:
-@file{file_name.###}, where @code{###} is a number that is incremented each
-time you execute @code{mysqladmin refresh}, execute @code{mysqladmin
-flush-logs}, execute the @code{FLUSH LOGS} statement, or restart the server.
-
-@strong{NOTE:} For the above scheme to work, you should NOT create
-your own files with the same filename as the update log + some extensions
-that may be regarded as a number, in the directory used by the update log!
-
-If you use the @code{--log} or @code{-l} options, @code{mysqld} writes a
-general log with a filename of @file{hostname.log}, and restarts and
-refreshes do not cause a new log file to be generated (although it is closed
-and reopened). In this case you can copy it (on Unix) by doing:
-
-@example
-mv hostname.log hostname-old.log
-mysqladmin flush-logs
-cp hostname-old.log to-backup-directory
-rm hostname-old.log
-@end example
-
-Update logging is smart because it logs only statements that really update
-data. So an @code{UPDATE} or a @code{DELETE} with a @code{WHERE} that finds no
-rows is not written to the log. It even skips @code{UPDATE} statements that
-set a column to the value it already has.
-
-The update logging is done immediately after a query completes but before
-any locks are released or any commit is done. This ensures that the log
-will be logged in the execution order.
-
-If you want to update a database from update log files, you could do the
-following (assuming your update logs have names of the form
-@file{file_name.###}):
-
-@example
-shell> ls -1 -t -r file_name.[0-9]* | xargs cat | mysql
-@end example
-
-@code{ls} is used to get all the log files in the right order.
-
-This can be useful if you have to revert to backup files after a crash
-and you want to redo the updates that occurred between the time of the backup
-and the crash.
-
-@cindex binary log
-@cindex files, binary log
-@node Binary log, Slow query log, Update log, Log files
-@section The Binary Log
-
-In the future the binary log will replace the update log, so we
-recommend you to switch to this log format as soon as possible!
-
-The binary log contains all information that is available in the update
-log in a more efficient format. It also contains information about how long
-every query that updated the database took.
-
-The binary log is also used when you are replicating a slave from a master.
-@xref{Replication}.
-
-When started with the @code{--log-bin[=file_name]} option, @code{mysqld}
-writes a log file containing all SQL commands that update data. If no
-file name is given, it defaults to the name of the host machine followed
-by @code{-bin}. If file name is given, but it doesn't contain a path, the
-file is written in the data directory.
-
-You can use the following options to @code{mysqld} to affect what is logged
-to the binary log:
-
-@multitable @columnfractions .4 .6
-@item @code{binlog-do-db=database_name} @tab
-Tells the master it should log updates for the specified database, and
-exclude all others not explicitly mentioned.
-(Example: @code{binlog-do-db=some_database})
-
-@item @code{binlog-ignore-db=database_name} @tab
-Tells the master that updates to the given database should not be logged
-to the binary log (Example: @code{binlog-ignore-db=some_database})
-@end multitable
-
-To the binary log filename @code{mysqld} will append an extension that is a
-number that is incremented each time you execute @code{mysqladmin
-refresh}, execute @code{mysqladmin flush-logs}, execute the @code{FLUSH LOGS}
-statement or restart the server.
-
-To be able to know which different binary log files have been used,
-@code{mysqld} will also create a binary log index file that
-contains the name of all used binary log files. By default this has the
-same name as the binary log file, with the extension @code{'.index'}.
-You can change the name of the binary log index file with the
-@code{--log-bin-index=[filename]} option.
-
-If you are using replication, you should not delete old binary log
-files until you are sure that no slave will ever need to use them.
-One way to do this is to do @code{mysqladmin flush-logs} once a day and then
-remove any logs that are more than 3 days old.
-
-You can examine the binary log file with the @code{mysqlbinlog} command.
-For example, you can update a @strong{MySQL} server from the binary log
-as follows:
-
-@example
-mysqlbinlog log-file | mysql -h server_name
-@end example
-
-You can also use the @code{mysqlbinlog} program to read the binary log
-directly from a remote @strong{MySQL} server!
-
-@code{mysqlbinlog --help} will give you more information of how to use
-this program!
-
-If you are using @code{BEGIN [WORK]} or @code{SET AUTOCOMMIT=0}, you must
-use the @strong{MySQL} binary log for backups instead of the old update log.
-
-The binary logging is done immediately after a query completes but before
-any locks are released or any commit is done. This ensures that the log
-will be logged in the execution order.
-
-All updates (@code{UPDATE}, @code{DELETE} or @code{INSERT}) that change
-a transactional table (like BDB tables) are cached until a @code{COMMIT}.
-Any updates to a non-transactional table are stored in the binary log at
-once. Every thread will, on start, allocate a buffer of
-@code{binlog_cache_size} to buffer queries. If a query is bigger than
-this, the thread will open a temporary file to handle the bigger cache.
-The temporary file will be deleted when the thread ends.
-
-The @code{max_binlog_cache_size} can be used to restrict the total size used
-to cache a multi-transaction query.
-
-If you are using the update or binary log, concurrent inserts will
-not work together with @code{CREATE ... INSERT} and @code{INSERT ... SELECT}.
-This is to ensure that you can recreate an exact copy of your tables by
-applying the log on a backup.
-
-@cindex slow query log
-@cindex files, slow query log
-@node Slow query log, , Binary log, Log files
-@section The Slow Query Log
-
-When started with the @code{--log-slow-queries[=file_name]} option,
-@code{mysqld} writes a log file containing all SQL commands that took
-more than @code{long_query_time} to execute. The time to get the initial
-table locks are not counted as execution time.
-
-The slow query log is logged after the query is executed and after all
-locks has been released. This may be different than the order in which
-the statements are executed.
-
-If no file name is given, it defaults to the name of the host machine
-suffixed with @code{-slow.log}. If a filename is given, but doesn't
-contain a path, the file is written in the data directory.
-
-The slow query log can be used to find queries that take a long time to
-execute and are thus candidates for optimization. With a large log, that
-can become a difficult task. You can pipe the slow query log through the
-@code{mysqldumpslow} command to get a summary of the queries which
-appear in the log.
-
-You are using @code{--log-long-format} then also queries that are not
-using indexes are printed. @xref{Command-line options}.
-
-@cindex database replication
-@cindex replication, database
-@cindex database mirroring
-@cindex mirroring, database
-You can also use the update logs when you have a mirrored database on
-another host and you want to replicate the changes that have been made
-to the master database. @xref{Log Replication}.
+@node Clients, MySQL internals, Common problems, Top
+@chapter MySQL APIs
@cindex client tools
@cindex APIs
@cindex @code{mysqlclient} library
@cindex buffer sizes, client
@cindex library, @code{mysqlclient}
-@node Clients, MySQL internals, Log files, Top
-@chapter MySQL APIs
@menu
* C:: @strong{MySQL} C API
@@ -38931,7 +39785,7 @@ Most of the other client APIs (all except Java) use the @code{mysqlclient}
library to communicate with the @strong{MySQL} server. This means that, for
example, you can take advantage of many of the same environment variables
that are used by other client programs, because they are referenced from the
-library. See @ref{Programs}, for a list of these variables.
+library. See @ref{Client-Side Scripts}, for a list of these variables.
The client has a maximum communication buffer size. The size of the buffer
that is allocated initially (16K bytes) is automatically increased up to the
@@ -51721,9 +52575,6 @@ That's all there is to it!
@menu
* Installing binary::
* Building clients::
-* Command-line options::
-* Option files::
-* Installing many servers::
* Perl support::
@end menu
@@ -51944,7 +52795,7 @@ shell> bin/safe_mysqld --user=mysql &
@xref{Post-installation}.
-@node Building clients, Command-line options, Installing binary, Placeholder
+@node Building clients, Perl support, Installing binary, Placeholder
@appendixsec Building Client Programs
@cindex client programs, building
@@ -51965,516 +52816,10 @@ For clients that use @strong{MySQL} header files, you may need to specify a
files.
-@node Command-line options, Option files, Building clients, Placeholder
-@appendixsec mysqld Command-line Options
-
-@findex command-line options
-@cindex options, command-line
-@cindex mysqld options
-
-@code{mysqld} accepts the following command-line options:
-
-@table @code
-@item --ansi
-Use ANSI SQL syntax instead of MySQL syntax. @xref{ANSI mode}.
-
-@item -b, --basedir=path
-Path to installation directory. All paths are usually resolved relative to
-this.
-@item --big-tables
-Allow big result sets by saving all temporary sets on file. It solves
-most 'table full' errors, but also slows down the queries where
-in-memory tables would suffice. Since Version 3.23.2, @strong{MySQL} is
-able to solve it automatically by using memory for small temporary
-tables and switching to disk tables where necessary.
-
-@item --bind-address=IP
-IP address to bind to.
-
-@item --character-sets-dir=path
-Directory where character sets are. @xref{Character sets}.
-
-@item --chroot=path
-Chroot @code{mysqld} daemon during startup. Recommended security measure. It will
-somewhat limit @code{LOAD DATA INFILE} and @code{SELECT ... INTO OUTFILE}
-though.
-
-@item --core-file
-Write a core file if @code{mysqld} dies. For some systems you must also
-specify @code{--core-file-size} to @code{safe_mysqld}. @xref{safe_mysqld, ,
-@code{safe_mysqld}}.
-
-@item -h, --datadir=path
-Path to the database root.
-
-@item --default-character-set=charset
-Set the default character set. @xref{Character sets}.
-
-@item --default-table-type=type
-Set the default table type for tables. @xref{Table types}.
-
-@item --debug[...]=
-If @strong{MySQL} is configured with @code{--with-debug}, you can use this
-option to get a trace file of what @code{mysqld} is doing.
-@xref{Making trace files}.
-
-@item --delay-key-write-for-all-tables
-Don't flush key buffers between writes for any @code{MyISAM} table.
-@xref{Server parameters}.
-
-@item --enable-locking
-Enable system locking. Note that if you use this option on a system
-which a not fully working lockd() (as on Linux) you will easily get
-mysqld to deadlock.
-
-@item -T, --exit-info
-This is a bit mask of different flags one can use for debugging the
-mysqld server; One should not use this option if one doesn't know
-exactly what it does!
-
-@item --flush
-Flush all changes to disk after each SQL command. Normally @strong{MySQL}
-only does a write of all changes to disk after each SQL command and lets
-the operating system handle the syncing to disk.
-@xref{Crashing}.
-
-@item -?, --help
-Display short help and exit.
-
-@item --init-file=file
-Read SQL commands from this file at startup.
-
-@item -L, --language=...
-Client error messages in given language. May be given as a full path.
-@xref{Languages}.
-
-@item -l, --log[=file]
-Log connections and queries to file. @xref{Query log}.
-
-@item --log-isam[=file]
-Log all ISAM/MyISAM changes to file (only used when debugging ISAM/MyISAM).
-
-@item --log-slow-queries[=file]
-Log all queries that have taken more than @code{long_query_time} seconds to
-execute to file. @xref{Slow query log}.
-
-@item --log-update[=file]
-Log updates to @code{file.#} where @code{#} is a unique number if not given.
-@xref{Update log}.
-
-@item --log-long-format
-Log some extra information to update log. If you are using
-@code{--log-slow-queries} then queries that are not using indexes are logged
-to the slow query log.
-
-@item --low-priority-updates
-Table-modifying operations (@code{INSERT}/@code{DELETE}/@code{UPDATE})
-will have lower priority than selects. It can also be done via
-@code{@{INSERT | REPLACE | UPDATE | DELETE@} LOW_PRIORITY ...} to lower
-the priority of only one query, or by
-@code{SET OPTION SQL_LOW_PRIORITY_UPDATES=1} to change the priority in one
-thread. @xref{Table locking}.
-
-@item --memlock
-Lock the @code{mysqld} process in memory. This works only if your
-system supports the @code{mlockall()} system call (like Solaris). This
-may help if you have a problem where the operating system is causing
-@code{mysqld} to swap on disk.
-
-@item --myisam-recover [=option[,option...]]] where option is one of DEFAULT, BACKUP, FORCE or QUICK.
-If this option is used, @code{mysqld} will on open check if the table is
-marked as crashed or if if the table wasn't closed properly. (The last
-option only works if you are running with @code{--skip-locking}). If this
-is the case @code{mysqld} will run check on the table. If the table was corrupted,
-@code{mysqld} will attempt to repair it.
-
-The following options affects how the repair works.
-
-@multitable @columnfractions .3 .7
-@item DEFAULT @tab The same as not giving any option to
- @code{--myisam-recover}.
-@item BACKUP @tab If the data table was changed during recover, save a
- backup of the @file{table_name.MYD} data file as
- @file{table_name-datetime.BAK}.
-@item FORCE @tab Run recover even if we will loose more than one row
- from the .MYD file.
-@item QUICK @tab Don't check the rows in the table if there isn't any
- delete blocks.
-@end multitable
-
-Before a table is automatically repaired, @strong{MySQL} will add a note
-about this in the error log. If you want to be able to recover from most
-things without user intervention, you should use the options
-@code{BACKUP,FORCE}. This will force a repair of a table even if some rows
-would be deleted, but it will keep the old data file as a backup so that
-you can later examine what happened.
-
-@item --pid-file=path
-Path to pid file used by @code{safe_mysqld}.
-
-@item -P, --port=...
-Port number to listen for TCP/IP connections.
-
-@item -o, --old-protocol
-Use the 3.20 protocol for compatibility with some very old clients.
-@xref{Upgrading-from-3.20}.
-
-@item --one-thread
-Only use one thread (for debugging under Linux). @xref{Debugging server}.
-
-@item -O, --set-variable var=option
-Give a variable a value. @code{--help} lists variables. You can find a full
-description for all variables in the @code{SHOW VARIABLES} section in this
-manual. @xref{SHOW VARIABLES}. The tuning server parameters section includes
-information of how to optimize these. @xref{Server parameters}.
-
-@item --safe-mode
-Skip some optimize stages. Implies @code{--skip-delay-key-write}.
-
-@item --safe-show-database
-Don't show databases for which the user doesn't have any privileges.
-
-@item --secure
-IP numbers returned by the @code{gethostbyname()} system call are
-checked to make sure they resolve back to the original hostname. This
-makes it harder for someone on the outside to get access by pretending
-to be another host. This option also adds some sanity checks of
-hostnames. The option is turned off by default in @strong{MySQL} Version 3.21
-because sometimes it takes a long time to perform backward resolutions.
-@strong{MySQL} Version 3.22 caches hostnames (unless @code{--skip-host-cache}
-is used) and has this option enabled by default.
-
-@item --skip-concurrent-insert
-Turn off the ability to select and insert at the same time on @code{MyISAM}
-tables. (This is only to be used if you think you have found a bug in this
-feature).
-
-@item --skip-delay-key-write
-Ignore the @code{delay_key_write} option for all tables.
-@xref{Server parameters}.
-
-@item --skip-grant-tables
-This option causes the server not to use the privilege system at all. This
-gives everyone @emph{full access} to all databases! (You can tell a running
-server to start using the grant tables again by executing @code{mysqladmin
-flush-privileges} or @code{mysqladmin reload}.)
-
-@item --skip-host-cache
-Never use host name cache for faster name-ip resolution, but query DNS server
-on every connect instead. @xref{DNS}.
-
-@item --skip-locking
-Don't use system locking. To use @code{isamchk} or @code{myisamchk} you must
-shut down the server. @xref{Stability}. Note that in @strong{MySQL} Version
-3.23 you can use @code{REPAIR} and @code{CHECK} to repair/check @code{MyISAM}
-tables.
-
-@item --skip-name-resolve
-Hostnames are not resolved. All @code{Host} column values in the grant tables
-must be IP numbers or @code{localhost}. @xref{DNS}.
-
-@item --skip-networking
-Don't listen for TCP/IP connections at all. All interaction with
-@code{mysqld} must be made via Unix sockets. This option is highly
-recommended for systems where only local requests are allowed. @xref{DNS}.
-
-@item --skip-new
-Don't use new, possible wrong routines. Implies @code{--skip-delay-key-write}.
-This will also set default table type to @code{ISAM}. @xref{ISAM}.
-
-@item --skip-symlink
-Don't delete or rename files that a symlinked file in the data directory
-points to.
-
-@item --skip-safemalloc
-If @strong{MySQL} is configured with @code{--with-debug=full}, all programs
-will check the memory for overruns for every memory allocation and memory
-freeing. As this checking is very slow, you can avoid this, when you don't
-need memory checking, by using this option.
-
-@item --skip-show-database
-Don't allow 'SHOW DATABASE' commands, unless the user has @strong{process}
-privilege.
-
-@item --skip-stack-trace
-Don't write stack traces. This option is useful when you are running
-@code{mysqld} under a debugger. @xref{Debugging server}.
-
-@item --skip-thread-priority
-Disable using thread priorities for faster response time.
-
-@item --socket=path
-Socket file to use for local connections instead of default
-@code{/tmp/mysql.sock}.
-
-@item transaction-isolation= @{ READ-UNCOMMITTED | READ-COMMITTED | REPEATABLE-READ | SERIALIZABLE @}
-Sets the default transaction isolation level. @xref{SET TRANSACTION}.
-
-@item -t, --tmpdir=path
-Path for temporary files. It may be useful if your default @code{/tmp}
-directory resides on a partition too small to hold temporary tables.
-
-@item -u, --user=user_name
-Run @code{mysqld} daemon as user @code{user_name}. This option is
-@emph{mandatory} when starting @code{mysqld} as root.
-
-@item -V, --version
-Output version information and exit.
-
-@item -W, --warnings
-Print out warnings like @code{Aborted connection...} to the @code{.err} file.
-@xref{Communication errors}.
-@end table
-
-@node Option files, Installing many servers, Command-line options, Placeholder
-@appendixsec Option Files
-
-@cindex default options
-@cindex option files
-@cindex creating, default startup options
-@cindex startup options, default
-
-@strong{MySQL} can, since Version 3.22, read default startup options for the
-server and for clients from option files.
-
-@strong{MySQL} reads default options from the following files on Unix:
-
-@tindex .my.cnf file
-@multitable @columnfractions .3 .7
-@item @strong{Filename} @tab @strong{Purpose}
-@item @code{/etc/my.cnf} @tab Global options
-@item @code{DATADIR/my.cnf} @tab Server-specific options
-@item @code{defaults-extra-file} @tab The file specified with --defaults-extra-file=#
-@item @code{~/.my.cnf} @tab User-specific options
-@end multitable
-
-@code{DATADIR} is the @strong{MySQL} data directory (typically
-@file{/usr/local/mysql/data} for a binary installation or
-@file{/usr/local/var} for a source installation). Note that this is the
-directory that was specified at configuration time, not the one specified
-with @code{--datadir} when @code{mysqld} starts up! (@code{--datadir} has no
-effect on where the server looks for option files, because it looks for them
-before it processes any command-line arguments.)
-
-@strong{MySQL} reads default options from the following files on Windows:
-
-@multitable @columnfractions .3 .7
-@item @strong{Filename} @tab @strong{Purpose}
-@item @code{windows-system-directory\my.ini} @tab Global options
-@item @code{C:\my.cnf} @tab Global options
-@item @code{C:\mysql\data\my.cnf} @tab Server-specific options
-@end multitable
-
-Note that on Windows, you should specify all paths with @code{/} instead of
-@code{\}. If you use @code{\}, you need to specify this twice, as
-@code{\} is the escape character in @strong{MySQL}.
-
-@cindex Environment variables
-@strong{MySQL} tries to read option files in the order listed above. If
-multiple option files exist, an option specified in a file read later takes
-precedence over the same option specified in a file read earlier. Options
-specified on the command line take precedence over options specified in any
-option file. Some options can be specified using environment variables.
-Options specified on the command line or in option files take precedence over
-environment variable values. @xref{Environment variables}.
-
-The following programs support option files: @code{mysql},
-@code{mysqladmin}, @code{mysqld}, @code{mysqldump}, @code{mysqlimport},
-@code{mysql.server}, @code{myisamchk}, and @code{myisampack}.
-
-You can use option files to specify any long option that a program supports!
-Run the program with @code{--help} to get a list of available options.
-
-An option file can contain lines of the following forms:
-
-@table @code
-@item #comment
-Comment lines start with @samp{#} or @samp{;}. Empty lines are ignored.
-
-@item [group]
-@code{group} is the name of the program or group for which you want to set
-options. After a group line, any @code{option} or @code{set-variable} lines
-apply to the named group until the end of the option file or another group
-line is given.
-
-@item option
-This is equivalent to @code{--option} on the command line.
-
-@item option=value
-This is equivalent to @code{--option=value} on the command line.
-
-@item set-variable = variable=value
-This is equivalent to @code{--set-variable variable=value} on the command line.
-This syntax must be used to set a @code{mysqld} variable.
-@end table
-
-The @code{client} group allows you to specify options that apply to all
-@strong{MySQL} clients (not @code{mysqld}). This is the perfect group to use
-to specify the password you use to connect to the server. (But make
-sure the option file is readable and writable only by yourself.)
-
-Note that for options and values, all leading and trailing blanks are
-automatically deleted. You may use the escape sequences @samp{\b},
-@samp{\t}, @samp{\n}, @samp{\r}, @samp{\\}, and @samp{\s} in your value string
-(@samp{\s} == blank).
-
-Here is a typical global option file:
-
-@example
-[client]
-port=3306
-socket=/tmp/mysql.sock
-
-[mysqld]
-port=3306
-socket=/tmp/mysql.sock
-set-variable = key_buffer_size=16M
-set-variable = max_allowed_packet=1M
-
-[mysqldump]
-quick
-@end example
-
-Here is typical user option file:
-
-@example
-[client]
-# The following password will be sent to all standard MySQL clients
-password=my_password
-
-[mysql]
-no-auto-rehash
-set-variable = connect_timeout=2
-
-[mysqlhotcopy]
-interactive-timeout
-
-@end example
-
-@tindex .my.cnf file
-If you have a source distribution, you will find sample configuration
-files named @file{my-xxxx.cnf} in the @file{support-files} directory.
-If you have a binary distribution, look in the @file{DIR/support-files}
-directory, where @code{DIR} is the pathname to the @strong{MySQL}
-installation directory (typically @file{/usr/local/mysql}). Currently
-there are sample configuration files for small, medium, large, and very
-large systems. You can copy @file{my-xxxx.cnf} to your home directory
-(rename the copy to @file{.my.cnf}) to experiment with this.
-
-All @strong{MySQL} clients that support option files support the
-following options:
-
-@multitable @columnfractions .40 .60
-@item --no-defaults @tab Don't read any option files.
-@item --print-defaults @tab Print the program name and all options that it will get.
-@item --defaults-file=full-path-to-default-file @tab Only use the given configuration file.
-@item --defaults-extra-file=full-path-to-default-file @tab Read this configuration file after the global configuration file but before the user configuration file.
-@end multitable
-
-Note that the above options must be first on the command line to work!
-@code{--print-defaults} may however be used directly after the
-@code{--defaults-xxx-file} commands.
-
-Note for developers: Option file handling is implemented simply by
-processing all matching options (that is, options in the appropriate group)
-before any command-line arguments. This works nicely for programs that use
-the last instance of an option that is specified multiple times. If you have
-an old program that handles multiply-specified options this way but doesn't
-read option files, you need add only two lines to give it that capability.
-Check the source code of any of the standard @strong{MySQL} clients to see
-how to do this.
-
-In shell scripts you can use the @file{my_print_defaults} command to parse the
-config files:
-
-@example
-
-shell> my_print_defaults client mysql
---port=3306
---socket=/tmp/mysql.sock
---no-auto-rehash
-@end example
-
-The above output contains all options for the groups 'client' and 'mysql'.
-
-
-@node Installing many servers, Perl support, Option files, Placeholder
-@appendixsec Installing Many Servers on the Same Machine
-
-@cindex post-install, many servers
-@cindex Installing many servers
-@cindex Starting many servers
-
-In some cases you may want to have many different @code{mysqld} daemons
-(servers) running on the same machine. You may for example want to run
-a new version of @strong{MySQL} for testing together with an old version
-that is in production. Another case is when you want to give different
-users access to different @code{mysqld} servers that they manage themselves.
-
-One way to get a new server running is by starting it with a different
-socket and port as follows:
-
-@tindex MYSQL_UNIX_PORT environment variable
-@tindex MYSQL_TCP_PORT environment variable
-@tindex Environment variable, MYSQL_UNIX_PORT
-@tindex Environment variable, MYSQL_TCP_PORT
-@example
-shell> MYSQL_UNIX_PORT=/tmp/mysqld-new.sock
-shell> MYSQL_TCP_PORT=3307
-shell> export MYSQL_UNIX_PORT MYSQL_TCP_PORT
-shell> scripts/mysql_install_db
-shell> bin/safe_mysqld &
-@end example
-
-The environment variables appendix includes a list of other environment
-variables you can use to affect @code{mysqld}. @xref{Environment variables}.
-
-The above is the quick and dirty way that one commonly uses for testing.
-The nice thing with this is that all connections you do in the above shell
-will automatically be directed to the new running server!
-
-If you need to do this more permanently, you should create an option
-file for each server. @xref{Option files}. In your startup script that
-is executed at boot time (mysql.server?) you should specify for both
-servers:
-
-@code{safe_mysqld --default-file=path-to-option-file}
-
-At least the following options should be different per server:
-
-@table @code
-@item port=#
-@item socket=path
-@item pid-file=path
-@end table
-
-The following options should be different, if they are used:
-
-@table @code
-@item log=path
-@item log-bin=path
-@item log-update=path
-@item log-isam=path
-@item bdb-logdir=path
-@end table
-
-If you want more performance, you can also specify the following differently:
-
-@table @code
-@item tmpdir=path
-@item bdb-tmpdir=path
-@end table
-
-@xref{Command-line options}.
-
-If you are installing binary @strong{MySQL} versions (.tar files) and
-start them with @code{./bin/safe_mysqld} then in most cases the only
-option you need to add/change is the @code{socket} and @code{port}
-argument to @code{safe_mysqld}.
-@node Perl support, , Installing many servers, Placeholder
+@node Perl support, , Building clients, Placeholder
@appendixsec Perl Installation Comments
@cindex Perl, installing