@@ -25439,7 +25433,7 @@ variable @code{opened_tables}. If this is quite big, even if you
...
@@ -25439,7 +25433,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
haven't done alot of @code{FLUSH TABLES}, you should increase your table
cache. @xref{SHOW STATUS}.
cache. @xref{SHOW STATUS}.
@cindex tabls, too many
@cindex tables, too many
@node Creating many tables, Open tables, Table cache, System
@node Creating many tables, Open tables, Table cache, System
@subsection Drawbacks of creating large numbers of tables in the same database
@subsection Drawbacks of creating large numbers of tables in the same database
...
@@ -25793,7 +25787,7 @@ format table and it is possible to use a smaller static format table that
...
@@ -25793,7 +25787,7 @@ format table and it is possible to use a smaller static format table that
can be used to find the relevant rows when scanning the table.
can be used to find the relevant rows when scanning the table.
@end itemize
@end itemize
@cindexindexes, uses for
@cindexindexes, uses for
@node MySQL indexes, Query Speed, Data size, Performance
@node MySQL indexes, Query Speed, Data size, Performance
@section How @strong{MySQL} uses indexes
@section How @strong{MySQL} uses indexes
...
@@ -25871,8 +25865,8 @@ indexes exist on @code{col1} and @code{col2}, the optimizer tries to
...
@@ -25871,8 +25865,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
find the most restrictive index by deciding which index will find fewer
rows and using that index to fetch the rows.
rows and using that index to fetch the rows.
@cindex Indexes, leftmost prefix of
@cindex indexes, leftmost prefix of
@cindex Leftmost prefix of indexes
@cindex leftmost prefix of indexes
If the table has a multiple-column index, any leftmost prefix of the
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
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
have a three-column index on @code{(col1,col2,col3)}, you have indexed
...
@@ -25896,8 +25890,8 @@ leftmost prefixes of @code{(col1,col2,col3)}.
...
@@ -25896,8 +25890,8 @@ leftmost prefixes of @code{(col1,col2,col3)}.
@findex LIKE, and indexes
@findex LIKE, and indexes
@findex LIKE, and wildcards
@findex LIKE, and wildcards
@cindex Indexes, and @code{LIKE}
@cindex indexes, and @code{LIKE}
@cindex Wildcards, and @code{LIKE}
@cindex wildcards, and @code{LIKE}
@strong{MySQL} also uses indexes for @code{LIKE} comparisons if the argument
@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
to @code{LIKE} is a constant string that doesn't start with a wildcard
character. For example, the following @code{SELECT} statements use indexes:
character. For example, the following @code{SELECT} statements use indexes:
...
@@ -25921,7 +25915,7 @@ In the first statement, the @code{LIKE} value begins with a wildcard character.
...
@@ -25921,7 +25915,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.
In the second statement, the @code{LIKE} value is not a constant.
@findex IS NULL, and indexes
@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
Searching using @code{column_name IS NULL} will use indexes if column_name
is an index.
is an index.
...
@@ -26128,8 +26122,8 @@ or group functions (@code{COUNT()}, @code{MIN()}...)
...
@@ -26128,8 +26122,8 @@ or group functions (@code{COUNT()}, @code{MIN()}...)
For each sub-join, a simpler @code{WHERE} is constructed to get a fast
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
@code{WHERE} evaluation for each sub-join and also to skip records as
soon as possible.
soon as possible.
@cindex Constant table
@cindex constant table
@cindex Table, constant
@cindex tables, constant
@item
@item
All constant tables are read first, before any other tables in the query.
All constant tables are read first, before any other tables in the query.
A constant table is:
A constant table is:
...
@@ -26965,8 +26959,8 @@ Use of @code{MYSQL_PWD} is insecure.
...
@@ -26965,8 +26959,8 @@ Use of @code{MYSQL_PWD} is insecure.
@tindex Environment variable, MYSQL_HISTFILE
@tindex Environment variable, MYSQL_HISTFILE
@tindex HOME environment variable
@tindex HOME environment variable
@tindex Environment variable, HOME
@tindex Environment variable, HOME
@cindex History file
@cindex history file
@cindex Command line history
@cindex command line history
@tindex .mysql_history file
@tindex .mysql_history file
The @file{mysql} client uses the file named in the @code{MYSQL_HISTFILE}
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
environment variable to save the command line history. The default value for
...
@@ -27092,63 +27086,88 @@ Using @code{mysql} is very easy; Just start it as follows
...
@@ -27092,63 +27086,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}
@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.
and press return/enter.
@cindex command line, options
@cindex options, command line
@cindex startup parameters
@code{mysql} supports the following options:
@code{mysql} supports the following options:
@table @code
@table @code
@cindex help option
@item -?, --help
@item -?, --help
Display this help and exit
Display this help and exit
@cindex automatic rehash option
@item -A, --no-auto-rehash
@item -A, --no-auto-rehash
No automatic rehashing. One has to use 'rehash' to get table and field
No automatic rehashing. One has to use 'rehash' to get table and field
completion. This gives a quicker start of mysql.
completion. This gives a quicker start of mysql.
@cindex batch option
@item -B, --batch
@item -B, --batch
Print results with a tab as separator, each row on a new line. Doesn't use
Print results with a tab as separator, each row on a new line. Doesn't use
history file.
history file.
@cindex character sets option
@item
@item
--character-sets-dir=...
--character-sets-dir=...
Directory where character sets are located.
Directory where character sets are located.
@cindex compress option.
@item -C, --compress
@item -C, --compress
Use compression in server/client protocol.
Use compression in server/client protocol.
@cindex debug option
@item -#, --debug[=...]
@item -#, --debug[=...]
Debug log. Default is 'd:t:o,/tmp/mysql.trace'
Debug log. Default is 'd:t:o,/tmp/mysql.trace'
@cindex database option
@item -D, --database=..
@item -D, --database=..
Database to use; This is mainly useful in the @code{my.cnf} file.
Database to use; This is mainly useful in the @code{my.cnf} file.
@cindex defualt character set option
@item
@item
--default-character-set=... Set the default character set.
--default-character-set=... Set the default character set.
@cindex execute option
@item -e, --execute=...
@item -e, --execute=...
Execute command and quit. (Output like with --batch)
Execute command and quit. (Output like with --batch)
@cindex vertcial option
@item -E, --vertical
@item -E, --vertical
Print the output of a query (rows) vertically. Without this option you
Print the output of a query (rows) vertically. Without this option you
can also force this output by ending your statements with @code{\G}.
can also force this output by ending your statements with @code{\G}.
@cindex force option
@item -f, --force
@item -f, --force
Continue even if we get an SQL error.
Continue even if we get an SQL error.
@cindex no-named-commands option
@item -g, --no-named-commands
@item -g, --no-named-commands
Named commands are disabled. Use \* form only, or use 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
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!
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
With the -g option, long format commands will still work from the first
line, however.
line, however.
@cindex enable-named-commands option
@item -G, --enable-named-commands
@item -G, --enable-named-commands
Named commands are @strong{enabled}. Long format commands are allowed as
Named commands are @strong{enabled}. Long format commands are allowed as
well as shortened \* commands.
well as shortened \* commands.
@cindex ignore space option.
@item -i, --ignore-space
@item -i, --ignore-space
Ignore space after function names.
Ignore space after function names.
@cindex host option
@item -h, --host=...
@item -h, --host=...
Connect to the given host.
Connect to the given host.
@cindex html option
@item -H, --html
@item -H, --html
Produce HTML output.
Produce HTML output.
@cindex skip line numbers option
@item -L, --skip-line-numbers
@item -L, --skip-line-numbers
Don't write line number for errors. Useful when one want's to compare result
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
@item -n, --unbuffered
Flush buffer after each query.
Flush buffer after each query.
@cindex skip column names option
@item -N, --skip-column-names
@item -N, --skip-column-names
Don't write column names in results.
Don't write column names in results.
@cindex set variable option
@item -O, --set-variable var=option
@item -O, --set-variable var=option
Give a variable a value. @code{--help} lists variables.
Give a variable a value. @code{--help} lists variables.
@cindex one database option
@item -o, --one-database
@item -o, --one-database
Only update the default database. This is useful for skipping updates to
Only update the default database. This is useful for skipping updates to
other database in the update log.
other database in the update log.
@item
@item
@cindex password option
@item -p[password], --password[=...]
@item -p[password], --password[=...]
Password to use when connecting to server. If password is not given on
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
the command line, you will be prompted for it. Note that if you use the
...
@@ -27156,29 +27175,38 @@ short form @code{-p} you can't have a space between the option and the
...
@@ -27156,29 +27175,38 @@ short form @code{-p} you can't have a space between the option and the
password.
password.
@item -P --port=...
@item -P --port=...
TCP/IP port number to use for connection.
TCP/IP port number to use for connection.
@cindex quick option
@item -q, --quick
@item -q, --quick
Don't cache result, print it row-by-row. This may slow down the server
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.
if the output is suspended. Doesn't use history file.
@cindex raw option
@item -r, --raw
@item -r, --raw
Write column values without escape conversion. Used with @code{--batch}
Write column values without escape conversion. Used with @code{--batch}
@cindex silent option
@item -s, --silent
@item -s, --silent
Be more silent.
Be more silent.
@item -S --socket=...
@item -S --socket=...
Socket file to use for connection.
Socket file to use for connection.
@cindex table option
@item -t --table
@item -t --table
Output in table format. This is default in non-batch mode.
Output in table format. This is default in non-batch mode.
@item -T, --debug-info
@item -T, --debug-info
Print some debug info at exit.
Print some debug info at exit.
@cindex user option
@item -u, --user=#
@item -u, --user=#
User for login if not current user.
User for login if not current user.
@cindex safe updates option
@item -U, --safe-updates[=#], --i-am-a-dummy[=#]
@item -U, --safe-updates[=#], --i-am-a-dummy[=#]
Only allow @code{UPDATE} and @code{DELETE} that uses keys. See below for
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
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}.
it in your @code{my.cnf} file by using @code{--safe-updates=0}.
@cindex verbose option
@item -v, --verbose
@item -v, --verbose
More verbose output (-v -v -v gives the table output format).
More verbose output (-v -v -v gives the table output format).
@cindex version option
@item -V, --version
@item -V, --version
Output version information and exit.
Output version information and exit.
@cindex wait option
@item -w, --wait
@item -w, --wait
Wait and retry if connection is down instead of aborting.
Wait and retry if connection is down instead of aborting.
@end table
@end table
...
@@ -27186,6 +27214,7 @@ Wait and retry if connection is down instead of aborting.
...
@@ -27186,6 +27214,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
If you type 'help' on the command line, @code{mysql} will print out the
commands that it supports:
commands that it supports:
@cindex commands, list of
@example
@example
mysql> help
mysql> help
...
@@ -27206,11 +27235,13 @@ status (\s) Get status information from the server
...
@@ -27206,11 +27235,13 @@ status (\s) Get status information from the server
use (\u) Use another database. Takes database name as argument
use (\u) Use another database. Takes database name as argument
@end example
@end example
@cindex status command
The @code{status} command gives you some information about the
The @code{status} command gives you some information about the
connection and the server you are using. If you are running in 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
@code{--safe-updates} mode, @code{status} will also print the values for
the @code{mysql} variables that affects your queries.
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
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
@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}
time done a @code{DELETE FROM table_name} but forgot the @code{WHERE}
...
@@ -27242,6 +27273,9 @@ All big results are automatically limited to @code{#select_limit#} rows.
...
@@ -27242,6 +27273,9 @@ All big results are automatically limited to @code{#select_limit#} rows.
@code{#max_join_size} row combinations will be aborted.
@code{#max_join_size} row combinations will be aborted.
@end itemize
@end itemize
@cindex administration, server
@cindex server, administration
@cindex mysladmn
@node mysqladmin, mysqldump, mysql, Tools
@node mysqladmin, mysqldump, mysql, Tools
@section Administering a MySQL server
@section Administering a MySQL server
...
@@ -27290,17 +27324,28 @@ shell> mysqladmin proc stat
...
@@ -27290,17 +27324,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
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
@end example
@cindex status command, results
The @code{mysqladmin status} command result has the following columns:
The @code{mysqladmin status} command result has the following columns:
@multitable @columnfractions .3 .7
@multitable @columnfractions .3 .7
@cindex uptime
@item Uptime @tab Number of seconds the @strong{MySQL} server has been up.
@item Uptime @tab Number of seconds the @strong{MySQL} server has been up.
@cindex threads
@item Threads @tab Number of active threads (clients).
@item Threads @tab Number of active threads (clients).
@cindex questions
@item Questions @tab Number of questions from clients since @code{mysqld} was started.
@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}.
@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.
@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.
@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.
@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).
@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).
@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
@end multitable
...
@@ -27308,10 +27353,14 @@ If you do @code{myslqadmin shutdown} on a socket (in other words, on a
...
@@ -27308,10 +27353,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
the computer where @code{mysqld} is running), @code{mysqladmin} will
wait until the @strong{MySQL} @code{pid-file} is removed to ensure that
wait until the @strong{MySQL} @code{pid-file} is removed to ensure that
the @code{mysqld} server has stopped properly.
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
@node mysqldump, mysqlimport, mysqladmin, Tools
@section Dumping the structure and data from MySQL databases and tables
@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
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
for transferring the data to another SQL server. The dump will contain SQL
statements to create the table and/or populate the table.
statements to create the table and/or populate the table.
...
@@ -27487,6 +27536,11 @@ If all the databases are wanted, one can use:
...
@@ -27487,6 +27536,11 @@ If all the databases are wanted, one can use:
mysqldump --all-databases > all_databases.sql
mysqldump --all-databases > all_databases.sql
@end example
@end example
@cindex importing, data
@cindex data, importing
@cindex files, text
@cindex text files, importing
@cindex mysqlimport
@node mysqlimport, mysqlshow, mysqldump, Tools
@node mysqlimport, mysqlshow, mysqldump, Tools
@section Importing data from text files
@section Importing data from text files
...
@@ -27624,6 +27678,11 @@ $ mysql -e 'SELECT * FROM imptest' test
...
@@ -27624,6 +27678,11 @@ $ mysql -e 'SELECT * FROM imptest' test
+------+---------------+
+------+---------------+
@end example
@end example
@cindex databases, displaying
@cindex displaying, database information
@cindex tables, displaying
@cindex columns, displaying
@cindex showing, database information
@node mysqlshow, myisampack, mysqlimport, Tools
@node mysqlshow, myisampack, mysqlimport, Tools
@section Showing databases, tables and columns
@section Showing databases, tables and columns
...
@@ -27660,6 +27719,9 @@ the table names that matches the pattern. This is easily fixed by
...
@@ -27660,6 +27719,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
adding an extra @code{%} last on the command line (as a separate
argument).
argument).
@cindex compressed tables
@cindex tables, compressed
@cindex MyISAM, compressed tables
@cindex @code{myisampack}
@cindex @code{myisampack}
@cindex @code{pack_isam}
@cindex @code{pack_isam}
@node myisampack, , mysqlshow, Tools
@node myisampack, , mysqlshow, Tools
...
@@ -27759,6 +27821,7 @@ invoke @code{myisampack} if the table might be updated during the
...
@@ -27759,6 +27821,7 @@ invoke @code{myisampack} if the table might be updated during the
packing process.
packing process.
@end table
@end table
@cindex examples, compressed tables
The sequence of commands shown below illustrates a typical table compression
The sequence of commands shown below illustrates a typical table compression
session:
session:
...
@@ -28035,6 +28098,13 @@ After you have installed the packed table into the @strong{MySQL} database
...
@@ -28035,6 +28098,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}
directory you should do @code{mysqladmin flush-tables} to force @code{mysqld}