@@ -25479,7 +25473,7 @@ variable @code{opened_tables}. If this is quite big, even if you
haven't done alot of @code{FLUSH TABLES}, you should increase your table
cache. @xref{SHOW STATUS}.
@cindex tabls, too many
@cindex tables, too many
@node Creating many tables, Open tables, Table cache, System
@subsection Drawbacks of creating large numbers of tables in the same database
...
...
@@ -25911,8 +25905,8 @@ indexes exist on @code{col1} and @code{col2}, the optimizer tries to
find the most restrictive index by deciding which index will find fewer
rows and using that index to fetch the rows.
@cindex Indexes, leftmost prefix of
@cindex Leftmost prefix of indexes
@cindex indexes, leftmost prefix of
@cindex leftmost prefix of indexes
If the table has a multiple-column index, any leftmost prefix of the
index can be used by the optimizer to find rows. For example, if you
have a three-column index on @code{(col1,col2,col3)}, you have indexed
...
...
@@ -25936,8 +25930,8 @@ leftmost prefixes of @code{(col1,col2,col3)}.
@findex LIKE, and indexes
@findex LIKE, and wildcards
@cindex Indexes, and @code{LIKE}
@cindex Wildcards, and @code{LIKE}
@cindex indexes, and @code{LIKE}
@cindex wildcards, and @code{LIKE}
@strong{MySQL} also uses indexes for @code{LIKE} comparisons if the argument
to @code{LIKE} is a constant string that doesn't start with a wildcard
character. For example, the following @code{SELECT} statements use indexes:
...
...
@@ -25961,7 +25955,7 @@ In the first statement, the @code{LIKE} value begins with a wildcard character.
In the second statement, the @code{LIKE} value is not a constant.
@findex IS NULL, and indexes
@cindex Indexes, and @code{IS NULL}
@cindex indexes, and @code{IS NULL}
Searching using @code{column_name IS NULL} will use indexes if column_name
is an index.
...
...
@@ -26168,8 +26162,8 @@ or group functions (@code{COUNT()}, @code{MIN()}...)
For each sub-join, a simpler @code{WHERE} is constructed to get a fast
@code{WHERE} evaluation for each sub-join and also to skip records as
soon as possible.
@cindex Constant table
@cindex Table, constant
@cindex constant table
@cindex tables, constant
@item
All constant tables are read first, before any other tables in the query.
A constant table is:
...
...
@@ -27005,8 +26999,8 @@ Use of @code{MYSQL_PWD} is insecure.
@tindex Environment variable, MYSQL_HISTFILE
@tindex HOME environment variable
@tindex Environment variable, HOME
@cindex History file
@cindex Command line history
@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
...
...
@@ -27132,63 +27126,88 @@ 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 defualt 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 vertcial 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 an 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 want's to compare result
files that includes error messages.
files that includes error messages
@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.
@item
@cindex password option
@item -p[password], --password[=...]
Password to use when connecting to server. If password is not given on
the command line, you will be prompted for it. Note that if you use the
...
...
@@ -27196,29 +27215,38 @@ 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 info at exit.
@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
...
...
@@ -27226,6 +27254,7 @@ Wait and retry if connection is down instead of aborting.
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
...
...
@@ -27246,11 +27275,13 @@ status (\s) Get status information from the server
use (\u) Use another database. Takes database name as argument
@end example
@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 affects your queries.
@cindex safe-mode command
A useful startup option for beginners (introduced in @strong{MySQL} 3.23.11) is
@code{--safe-mode} (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}
...
...
@@ -27282,6 +27313,9 @@ All big results are automatically limited to @code{#select_limit#} rows.
@code{#max_join_size} row combinations will be aborted.
@end itemize
@cindex administration, server
@cindex server, administration
@cindex mysladmn
@node mysqladmin, mysqldump, mysql, Tools
@section Administering a MySQL server
...
...
@@ -27330,17 +27364,28 @@ shell> mysqladmin proc stat
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:
@multitable @columnfractions .3 .7
@cindex uptime
@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 in use
@item Memory in use @tab Memory allocated directly by the mysqld code (only available when @strong{MySQL} is compiled with --with-debug).
@cindex max memoory used
@item Max memory used @tab Maximum memory allocated directly by the mysqld code (only available when @strong{MySQL} is compiled with --with-debug).
@end multitable
...
...
@@ -27348,10 +27393,14 @@ 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, mysqlimport, mysqladmin, Tools
@section Dumping the structure and data from MySQL databases and tables
@cindex mysqldump
Utility to dump a database or a collection of database for backup or
for transferring the data to another SQL server. The dump will contain SQL
statements to create the table and/or populate the table.
...
...
@@ -27527,6 +27576,11 @@ If all the databases are wanted, one can use:
mysqldump --all-databases > all_databases.sql
@end example
@cindex importing, data
@cindex data, importing
@cindex files, text
@cindex text files, importing
@cindex mysqlimport
@node mysqlimport, mysqlshow, mysqldump, Tools
@section Importing data from text files
...
...
@@ -27664,6 +27718,11 @@ $ mysql -e 'SELECT * FROM imptest' test
+------+---------------+
@end example
@cindex databases, displaying
@cindex displaying, database information
@cindex tables, displaying
@cindex columns, displaying
@cindex showing, database information
@node mysqlshow, myisampack, mysqlimport, Tools
@section Showing databases, tables and columns
...
...
@@ -27700,6 +27759,9 @@ the table names that matches 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
...
...
@@ -27799,6 +27861,7 @@ 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:
...
...
@@ -28075,6 +28138,13 @@ After you have installed the packed table into the @strong{MySQL} database
directory you should do @code{mysqladmin flush-tables} to force @code{mysqld}