|
|
'\" t.\" Title: \fBmysql\fR.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author].\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>.\" Date: 04/06/2010.\" Manual: MySQL Database System.\" Source: MySQL 5.1.\" Language: English.\".TH "\FBMYSQL\FR" "1" "04/06/2010" "MySQL 5\&.1" "MySQL Database System".\" -----------------------------------------------------------------.\" * set default formatting.\" -----------------------------------------------------------------.\" disable hyphenation.nh.\" disable justification (adjust text to left margin only).ad l.\" -----------------------------------------------------------------.\" * MAIN CONTENT STARTS HERE *.\" -----------------------------------------------------------------.\" mysql.\" command-line tool.\" tools: command-line.\" scripts: SQL.\" SQL scripts.\" batch SQL files.SH "NAME"mysql \- the MySQL command\-line tool.SH "SYNOPSIS".HP \w'\fBmysql\ [\fR\fB\fIoptions\fR\fR\fB]\ \fR\fB\fIdb_name\fR\fR\ 'u\fBmysql [\fR\fB\fIoptions\fR\fR\fB] \fR\fB\fIdb_name\fR\fR.SH "DESCRIPTION".PP\fBmysql\fRis a simple SQL shell (with GNUreadlinecapabilities)\&. It supports interactive and noninteractive use\&. When used interactively, query results are presented in an ASCII\-table format\&. When used noninteractively (for example, as a filter), the result is presented in tab\-separated format\&. The output format can be changed using command options\&..PPIf you have problems due to insufficient memory for large result sets, use the\fB\-\-quick\fRoption\&. This forces\fBmysql\fRto retrieve results from the server a row at a time rather than retrieving the entire result set and buffering it in memory before displaying it\&. This is done by returning the result set using themysql_use_result()C API function in the client/server library rather thanmysql_store_result()\&..PPUsing\fBmysql\fRis very easy\&. Invoke it from the prompt of your command interpreter as follows:.sp.if n \{\.RS 4.\}.nfshell> \fBmysql \fR\fB\fIdb_name\fR\fR.fi.if n \{\.RE.\}.PPOr:.sp.if n \{\.RS 4.\}.nfshell> \fBmysql \-\-user=\fR\fB\fIuser_name\fR\fR\fB \-\-password=\fR\fB\fIyour_password\fR\fR\fB \fR\fB\fIdb_name\fR\fR.fi.if n \{\.RE.\}.PPThen type an SQL statement, end it with\(lq;\(rq,\eg, or\eGand press Enter\&..PPAs of MySQL 5\&.1\&.10, typing Control\-C causes\fBmysql\fRto attempt to kill the current statement\&. If this cannot be done, or Control\-C is typed again before the statement is killed,\fBmysql\fRexits\&. Previously, Control\-C caused\fBmysql\fRto exit in all cases\&..PPYou can execute SQL statements in a script file (batch file) like this:.sp.if n \{\.RS 4.\}.nfshell> \fBmysql \fR\fB\fIdb_name\fR\fR\fB < \fR\fB\fIscript\&.sql\fR\fR\fB > \fR\fB\fIoutput\&.tab\fR\fR.fi.if n \{\.RE.\}.SH "MYSQL OPTIONS".\" mysql command options.\" command options: mysql.\" options: command-line: mysql.\" startup parameters: mysql.PP\fBmysql\fRsupports the following options, which can be specified on the command line or in the[mysql]and[client]option file groups\&.\fBmysql\fRalso supports the options for processing option files described atSection\ \&4.2.3.3.1, \(lqCommand-Line Options that Affect Option-File Handling\(rq\&..sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: help option.\" help option: mysql\fB\-\-help\fR,\fB\-?\fR.spDisplay a help message and exit\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: auto-rehash option.\" auto-rehash option: mysql\fB\-\-auto\-rehash\fR.spEnable automatic rehashing\&. This option is on by default, which enables database, table, and column name completion\&. Use\fB\-\-disable\-auto\-rehash\fRto disable rehashing\&. That causes\fBmysql\fRto start faster, but you must issue therehashcommand if you want to use name completion\&..spTo complete a name, enter the first part and press Tab\&. If the name is unambiguous,\fBmysql\fRcompletes it\&. Otherwise, you can press Tab again to see the possible names that begin with what you have typed so far\&. Completion does not occur if there is no default database\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: batch option.\" batch option: mysql\fB\-\-batch\fR,\fB\-B\fR.spPrint results using tab as the column separator, with each row on a new line\&. With this option,\fBmysql\fRdoes not use the history file\&..spBatch mode results in nontabular output format and escaping of special characters\&. Escaping may be disabled by using raw mode; see the description for the\fB\-\-raw\fRoption\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: character-sets-dir option.\" character-sets-dir option: mysql\fB\-\-character\-sets\-dir=\fR\fB\fIpath\fR\fR.spThe directory where character sets are installed\&. SeeSection\ \&9.5, \(lqCharacter Set Configuration\(rq\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: column-names option.\" column-names option: mysql\fB\-\-column\-names\fR.spWrite column names in results\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: column-type-info option.\" column-type-info option: mysql\fB\-\-column\-type\-info\fR,\fB\-m\fR.spDisplay result set metadata\&. This option was added in MySQL 5\&.1\&.14\&. (Before that, use\fB\-\-debug\-info\fR\&.) The\fB\-m\fRshort option was added in MySQL 5\&.1\&.21\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: comments option.\" comments option: mysql\fB\-\-comments\fR,\fB\-c\fR.spWhether to preserve comments in statements sent to the server\&. The default is \-\-skip\-comments (discard comments), enable with \-\-comments (preserve comments)\&. This option was added in MySQL 5\&.1\&.23\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: compress option.\" compress option: mysql\fB\-\-compress\fR,\fB\-C\fR.spCompress all information sent between the client and the server if both support compression\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: database option.\" database option: mysql\fB\-\-database=\fR\fB\fIdb_name\fR\fR,\fB\-D \fR\fB\fIdb_name\fR\fR.spThe database to use\&. This is useful primarily in an option file\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: debug option.\" debug option: mysql\fB\-\-debug[=\fR\fB\fIdebug_options\fR\fR\fB]\fR,\fB\-# [\fR\fB\fIdebug_options\fR\fR\fB]\fR.spWrite a debugging log\&. A typical\fIdebug_options\fRstring is\'d:t:o,\fIfile_name\fR\'\&. The default is\'d:t:o,/tmp/mysql\&.trace\'\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: debug-check option.\" debug-check option: mysql\fB\-\-debug\-check\fR.spPrint some debugging information when the program exits\&. This option was added in MySQL 5\&.1\&.21\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: debug-info option.\" debug-info option: mysql\fB\-\-debug\-info\fR,\fB\-T\fR.spBefore MySQL 5\&.1\&.14, this option prints debugging information and memory and CPU usage statistics when the program exits, and also causes display of result set metadata during execution\&. As of MySQL 5\&.1\&.14, use\fB\-\-column\-type\-info\fRto display result set metadata\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: default-character-set option.\" default-character-set option: mysql\fB\-\-default\-character\-set=\fR\fB\fIcharset_name\fR\fR.spUse\fIcharset_name\fRas the default character set for the client and connection\&..spA common issue that can occur when the operating system usesutf8or another multi\-byte character set is that output from the\fBmysql\fRclient is formatted incorrectly, due to the fact that the MySQL client uses thelatin1character set by default\&. You can usually fix such issues by using this option to force the client to use the system character set instead\&..spSeeSection\ \&9.5, \(lqCharacter Set Configuration\(rq, for more information\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: delimiter option.\" delimiter option: mysql\fB\-\-delimiter=\fR\fB\fIstr\fR\fR.spSet the statement delimiter\&. The default is the semicolon character (\(lq;\(rq)\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: disable named commands.\" disable named command: mysql\fB\-\-disable\-named\-commands\fR.spDisable named commands\&. Use the\e*form only, or use named commands only at the beginning of a line ending with a semicolon (\(lq;\(rq)\&.\fBmysql\fRstarts with this option\fIenabled\fRby default\&. However, even with this option, long\-format commands still work from the first line\&. Seethe section called \(lqMYSQL COMMANDS\(rq\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: execute option.\" execute option: mysql\fB\-\-execute=\fR\fB\fIstatement\fR\fR,\fB\-e \fR\fB\fIstatement\fR\fR.spExecute the statement and quit\&. The default output format is like that produced with\fB\-\-batch\fR\&. SeeSection\ \&4.2.3.1, \(lqUsing Options on the Command Line\(rq, for some examples\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: force option.\" force option: mysql\fB\-\-force\fR,\fB\-f\fR.spContinue even if an SQL error occurs\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: host option.\" host option: mysql\fB\-\-host=\fR\fB\fIhost_name\fR\fR,\fB\-h \fR\fB\fIhost_name\fR\fR.spConnect to the MySQL server on the given host\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: html option.\" html option: mysql\fB\-\-html\fR,\fB\-H\fR.spProduce HTML output\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: ignore-spaces option.\" ignore-spaces option: mysql\fB\-\-ignore\-spaces\fR,\fB\-i\fR.spIgnore spaces after function names\&. The effect of this is described in the discussion for theIGNORE_SPACESQL mode (seeSection\ \&5.1.8, \(lqServer SQL Modes\(rq)\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: line-numbers option.\" line-numbers option: mysql\fB\-\-line\-numbers\fR.spWrite line numbers for errors\&. Disable this with\fB\-\-skip\-line\-numbers\fR\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: local-infile option.\" local-infile option: mysql\fB\-\-local\-infile[={0|1}]\fR.spEnable or disableLOCALcapability forLOAD DATA INFILE\&. With no value, the option enablesLOCAL\&. The option may be given as\fB\-\-local\-infile=0\fRor\fB\-\-local\-infile=1\fRto explicitly disable or enableLOCAL\&. EnablingLOCALhas no effect if the server does not also support it\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: named-commands option.\" named-commands option: mysql\fB\-\-named\-commands\fR,\fB\-G\fR.spEnable named\fBmysql\fRcommands\&. Long\-format commands are allowed, not just short\-format commands\&. For example,quitand\eqboth are recognized\&. Use\fB\-\-skip\-named\-commands\fRto disable named commands\&. Seethe section called \(lqMYSQL COMMANDS\(rq\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: no-auto-rehash option.\" no-auto-rehash option: mysql\fB\-\-no\-auto\-rehash\fR,\fB\-A\fR.spThis has the same effect as\fB\-skip\-auto\-rehash\fR\&. See the description for\fB\-\-auto\-rehash\fR\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: no-beep option.\" no-beep option: mysql\fB\-\-no\-beep\fR,\fB\-b\fR.spDo not beep when errors occur\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: no-named-commands option.\" no-named-commands option: mysql\fB\-\-no\-named\-commands\fR,\fB\-g\fR.spDeprecated, use\fB\-\-disable\-named\-commands\fRinstead\&.\fB\-\-no\-named\-commands\fRis removed in MySQL 5\&.5\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: no-pager option.\" no-pager option: mysql\fB\-\-no\-pager\fR.spDeprecated form of\fB\-\-skip\-pager\fR\&. See the\fB\-\-pager\fRoption\&.\fB\-\-no\-pager\fRis removed in MySQL 5\&.5\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: no-tee option.\" no-tee option: mysql\fB\-\-no\-tee\fR.spDeprecated form of\fB\-\-skip\-tee\fR\&. See the\fB\-\-tee\fRoption\&.\fB\-\-no\-tee\fRis removed in MySQL 5\&.5\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: one-database option.\" one-database option: mysql\fB\-\-one\-database\fR,\fB\-o\fR.spIgnore statements except those for the default database named on the command line\&. This is useful for skipping updates to other databases in the binary log\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: pager option.\" pager option: mysql\fB\-\-pager[=\fR\fB\fIcommand\fR\fR\fB]\fR.spUse the given command for paging query output\&. If the command is omitted, the default pager is the value of yourPAGERenvironment variable\&. Valid pagers are\fBless\fR,\fBmore\fR,\fBcat [> filename]\fR, and so forth\&. This option works only on Unix and only in interactive mode\&. To disable paging, use\fB\-\-skip\-pager\fR\&.the section called \(lqMYSQL COMMANDS\(rq, discusses output paging further\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: password option.\" password option: mysql\fB\-\-password[=\fR\fB\fIpassword\fR\fR\fB]\fR,\fB\-p[\fR\fB\fIpassword\fR\fR\fB]\fR.spThe password to use when connecting to the server\&. If you use the short option form (\fB\-p\fR), you\fIcannot\fRhave a space between the option and the password\&. If you omit the\fIpassword\fRvalue following the\fB\-\-password\fRor\fB\-p\fRoption on the command line,\fBmysql\fRprompts for one\&..spSpecifying a password on the command line should be considered insecure\&. SeeSection\ \&5.3.2.2, \(lqEnd-User Guidelines for Password Security\(rq\&. You can use an option file to avoid giving the password on the command line\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: pipe option.\" pipe option: mysql\fB\-\-pipe\fR,\fB\-W\fR.spOn Windows, connect to the server via a named pipe\&. This option applies only if the server supports named\-pipe connections\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: port option.\" port option: mysql\fB\-\-port=\fR\fB\fIport_num\fR\fR,\fB\-P \fR\fB\fIport_num\fR\fR.spThe TCP/IP port number to use for the connection\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: prompt option.\" prompt option: mysql\fB\-\-prompt=\fR\fB\fIformat_str\fR\fR.spSet the prompt to the specified format\&. The default ismysql>\&. The special sequences that the prompt can contain are described inthe section called \(lqMYSQL COMMANDS\(rq\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: protocol option.\" protocol option: mysql\fB\-\-protocol={TCP|SOCKET|PIPE|MEMORY}\fR.spThe connection protocol to use for connecting to the server\&. It is useful when the other connection parameters normally would cause a protocol to be used other than the one you want\&. For details on the allowable values, seeSection\ \&4.2.2, \(lqConnecting to the MySQL Server\(rq\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: quick option.\" quick option: mysql\fB\-\-quick\fR,\fB\-q\fR.spDo not cache each query result, print each row as it is received\&. This may slow down the server if the output is suspended\&. With this option,\fBmysql\fRdoes not use the history file\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: raw option.\" raw option: mysql\fB\-\-raw\fR,\fB\-r\fR.spFor tabular output, the\(lqboxing\(rqaround columns enables one column value to be distinguished from another\&. For nontabular output (such as is produced in batch mode or when the\fB\-\-batch\fRor\fB\-\-silent\fRoption is given), special characters are escaped in the output so they can be identified easily\&. Newline, tab,NUL, and backslash are written as\en,\et,\e0, and\e\e\&. The\fB\-\-raw\fRoption disables this character escaping\&..spThe following example demonstrates tabular versus nontabular output and the use of raw mode to disable escaping:.sp.if n \{\.RS 4.\}.nf% \fBmysql\fRmysql> SELECT CHAR(92);+\-\-\-\-\-\-\-\-\-\-+| CHAR(92) |+\-\-\-\-\-\-\-\-\-\-+| \e |+\-\-\-\-\-\-\-\-\-\-+% \fBmysql \-s\fRmysql> SELECT CHAR(92);CHAR(92)\e\e% \fBmysql \-s \-r\fRmysql> SELECT CHAR(92);CHAR(92)\e.fi.if n \{\.RE.\}.RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: reconnect option.\" reconnect option: mysql\fB\-\-reconnect\fR.spIf the connection to the server is lost, automatically try to reconnect\&. A single reconnect attempt is made each time the connection is lost\&. To suppress reconnection behavior, use\fB\-\-skip\-reconnect\fR\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: safe-updates option.\" safe-updates option: mysql.\" mysql: i-am-a-dummy option.\" i-am-a-dummy option: mysql\fB\-\-safe\-updates\fR,\fB\-\-i\-am\-a\-dummy\fR,\fB\-U\fR.spAllow only thoseUPDATEandDELETEstatements that specify which rows to modify by using key values\&. If you have set this option in an option file, you can override it by using\fB\-\-safe\-updates\fRon the command line\&. Seethe section called \(lqMYSQL TIPS\(rq, for more information about this option\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: secure-auth option.\" secure-auth option: mysql\fB\-\-secure\-auth\fR.spDo not send passwords to the server in old (pre\-4\&.1\&.1) format\&. This prevents connections except for servers that use the newer password format\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: show-warnings option.\" show-warnings option: mysql\fB\-\-show\-warnings\fR.spCause warnings to be shown after each statement if there are any\&. This option applies to interactive and batch mode\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: sigint-ignore option.\" sigint-ignore option: mysql\fB\-\-sigint\-ignore\fR.spIgnoreSIGINTsignals (typically the result of typing Control\-C)\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: silent option.\" silent option: mysql\fB\-\-silent\fR,\fB\-s\fR.spSilent mode\&. Produce less output\&. This option can be given multiple times to produce less and less output\&..spThis option results in nontabular output format and escaping of special characters\&. Escaping may be disabled by using raw mode; see the description for the\fB\-\-raw\fRoption\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: skip-column-names option.\" skip-column-names option: mysql\fB\-\-skip\-column\-names\fR,\fB\-N\fR.spDo not write column names in results\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: skip-line-numbers option.\" skip-line-numbers option: mysql\fB\-\-skip\-line\-numbers\fR,\fB\-L\fR.spDo not write line numbers for errors\&. Useful when you want to compare result files that include error messages\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: socket option.\" socket option: mysql\fB\-\-socket=\fR\fB\fIpath\fR\fR,\fB\-S \fR\fB\fIpath\fR\fR.spFor connections tolocalhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: SSL options.\" SSL options: mysql\fB\-\-ssl*\fR.spOptions that begin with\fB\-\-ssl\fRspecify whether to connect to the server via SSL and indicate where to find SSL keys and certificates\&. SeeSection\ \&5.5.6.3, \(lqSSL Command Options\(rq\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: table option.\" table option: mysql\fB\-\-table\fR,\fB\-t\fR.spDisplay output in table format\&. This is the default for interactive use, but can be used to produce table output in batch mode\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: tee option.\" tee option: mysql\fB\-\-tee=\fR\fB\fIfile_name\fR\fR.spAppend a copy of output to the given file\&. This option works only in interactive mode\&.the section called \(lqMYSQL COMMANDS\(rq, discusses tee files further\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: unbuffered option.\" unbuffered option: mysql\fB\-\-unbuffered\fR,\fB\-n\fR.spFlush the buffer after each query\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: user option.\" user option: mysql\fB\-\-user=\fR\fB\fIuser_name\fR\fR,\fB\-u \fR\fB\fIuser_name\fR\fR.spThe MySQL user name to use when connecting to the server\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: verbose option.\" verbose option: mysql\fB\-\-verbose\fR,\fB\-v\fR.spVerbose mode\&. Produce more output about what the program does\&. This option can be given multiple times to produce more and more output\&. (For example,\fB\-v \-v \-v\fRproduces table output format even in batch mode\&.).RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: version option.\" version option: mysql\fB\-\-version\fR,\fB\-V\fR.spDisplay version information and exit\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: vertical option.\" vertical option: mysql\fB\-\-vertical\fR,\fB\-E\fR.spPrint query output rows vertically (one line per column value)\&. Without this option, you can specify vertical output for individual statements by terminating them with\eG\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: wait option.\" wait option: mysql\fB\-\-wait\fR,\fB\-w\fR.spIf the connection cannot be established, wait and retry instead of aborting\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: xml option.\" xml option: mysql\fB\-\-xml\fR,\fB\-X\fR.spProduce XML output\&..if n \{\.sp.\}.RS 4.it 1 an-trap.nr an-no-space-flag 1.nr an-break-flag 1.br.ps +1\fBNote\fR.ps -1.brPrior to MySQL 5\&.1\&.12, there was no differentiation in the output when using this option between columns containing theNULLvalue and columns containing the string literal\'NULL\'; both were represented as.sp .5v.RE.sp.if n \{\.RS 4.\}.nf<field name="\fIcolumn_name\fR">NULL</field>.fi.if n \{\.RE.\}.spBeginning with MySQL 5\&.1\&.12, the output when\fB\-\-xml\fRis used with\fBmysql\fRmatches that of\fBmysqldump \fR\fB\fB\-\-xml\fR\fR\&. See\fBmysqldump\fR(1)for details\&..spBeginning with MySQL 5\&.1\&.18, the XML output also uses an XML namespace, as shown here:.sp.if n \{\.RS 4.\}.nfshell> \fBmysql \-\-xml \-uroot \-e "SHOW VARIABLES LIKE \'version%\'"\fR<?xml version="1\&.0"?><resultset statement="SHOW VARIABLES LIKE \'version%\'" xmlns:xsi="http://www\&.w3\&.org/2001/XMLSchema\-instance"><row><field name="Variable_name">version</field><field name="Value">5\&.0\&.40\-debug</field></row><row><field name="Variable_name">version_comment</field><field name="Value">Source distribution</field></row><row><field name="Variable_name">version_compile_machine</field><field name="Value">i686</field></row><row><field name="Variable_name">version_compile_os</field><field name="Value">suse\-linux\-gnu</field></row></resultset>.fi.if n \{\.RE.\}.sp(See\m[blue]\fBBug#25946\fR\m[]\&\s-2\u[1]\d\s+2\&.).RE.PPYou can also set the following variables by using\fB\-\-\fR\fB\fIvar_name\fR\fR\fB=\fR\fB\fIvalue\fR\fR\&. The\fB\-\-set\-variable\fRformat is deprecated and is removed in MySQL 5\&.5\&..sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" timeout: connect_timeout variable.\" connect_timeout variableconnect_timeout.spThe number of seconds before connection timeout\&. (Default value is0\&.).RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" max_allowed_packet variablemax_allowed_packet.spThe maximum packet length to send to or receive from the server\&. (Default value is 16MB\&.).RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" max_join_size variablemax_join_size.spThe automatic limit for rows in a join when using\fB\-\-safe\-updates\fR\&. (Default value is 1,000,000\&.).RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" net_buffer_length variablenet_buffer_length.spThe buffer size for TCP/IP and socket communication\&. (Default value is 16KB\&.).RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" select_limit variableselect_limit.spThe automatic limit forSELECTstatements when using\fB\-\-safe\-updates\fR\&. (Default value is 1,000\&.).RE.\" MYSQL_HISTFILE environment variable.\" environment variable: MYSQL_HISTFILE.\" HOME environment variable.\" environment variable: HOME.\" mysql history file.\" command-line history: mysql.\" .mysql_history file.PPOn Unix, the\fBmysql\fRclient writes a record of executed statements to a history file\&. By default, this file is named\&.mysql_historyand is created in your home directory\&. To specify a different file, set the value of theMYSQL_HISTFILEenvironment variable\&..PPThe\&.mysql_historyshould be protected with a restrictive access mode because sensitive information might be written to it, such as the text of SQL statements that contain passwords\&. SeeSection\ \&5.3.2.2, \(lqEnd-User Guidelines for Password Security\(rq\&..PPIf you do not want to maintain a history file, first remove\&.mysql_historyif it exists, and then use either of the following techniques:.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}Set theMYSQL_HISTFILEvariable to/dev/null\&. To cause this setting to take effect each time you log in, put the setting in one of your shell\'s startup files\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}Create\&.mysql_historyas a symbolic link to/dev/null:.sp.if n \{\.RS 4.\}.nfshell> \fBln \-s /dev/null $HOME/\&.mysql_history\fR.fi.if n \{\.RE.\}.spYou need do this only once\&..RE.SH "MYSQL COMMANDS".PP\fBmysql\fRsends each SQL statement that you issue to the server to be executed\&. There is also a set of commands that\fBmysql\fRitself interprets\&. For a list of these commands, typehelpor\ehat themysql>prompt:.\" mysql commands: list of.sp.if n \{\.RS 4.\}.nfmysql> \fBhelp\fRList of all MySQL commands:Note that all text commands must be first on line and end with \';\'? (\e?) Synonym for `help\'\&.clear (\ec) Clear command\&.connect (\er) Reconnect to the server\&. Optional arguments are db and host\&.delimiter (\ed) Set statement delimiter\&.edit (\ee) Edit command with $EDITOR\&.ego (\eG) Send command to mysql server, display result vertically\&.exit (\eq) Exit mysql\&. Same as quit\&.go (\eg) Send command to mysql server\&.help (\eh) Display this help\&.nopager (\en) Disable pager, print to stdout\&.notee (\et) Don\'t write into outfile\&.pager (\eP) Set PAGER [to_pager]\&. Print the query results via PAGER\&.print (\ep) Print current command\&.prompt (\eR) Change your mysql prompt\&.quit (\eq) Quit mysql\&.rehash (\e#) Rebuild completion hash\&.source (\e\&.) Execute an SQL script file\&. Takes a file name as an argument\&.status (\es) Get status information from the server\&.system (\e!) Execute a system shell command\&.tee (\eT) Set outfile [to_outfile]\&. Append everything into given outfile\&.use (\eu) Use another database\&. Takes database name as argument\&.charset (\eC) Switch to another charset\&. Might be needed for processing binlog with multi\-byte charsets\&.warnings (\eW) Show warnings after every statement\&.nowarning (\ew) Don\'t show warnings after every statement\&.For server side help, type \'help contents\'.fi.if n \{\.RE.\}.PPEach command has both a long and short form\&. The long form is not case sensitive; the short form is\&. The long form can be followed by an optional semicolon terminator, but the short form should not\&..PPThe use of short\-form commands within multi\-line/* \&.\&.\&. */comments is not supported\&..sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: help command.\" help command: mysql\fBhelp [\fR\fB\fIarg\fR\fR\fB]\fR,\fB\eh [\fR\fB\fIarg\fR\fR\fB]\fR,\fB\e? [\fR\fB\fIarg\fR\fR\fB]\fR,\fB? [\fR\fB\fIarg\fR\fR\fB]\fR.spDisplay a help message listing the available\fBmysql\fRcommands\&..spIf you provide an argument to thehelpcommand,\fBmysql\fRuses it as a search string to access server\-side help from the contents of the MySQL Reference Manual\&. For more information, seethe section called \(lqMYSQL SERVER-SIDE HELP\(rq\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: charset command.\" charset command: mysql\fBcharset \fR\fB\fIcharset_name\fR\fR,\fB\eC \fR\fB\fIcharset_name\fR\fR.spChange the default character set and issue aSET NAMESstatement\&. This enables the character set to remain synchronized on the client and server if\fBmysql\fRis run with auto\-reconnect enabled (which is not recommended), because the specified character set is used for reconnects\&. This command was added in MySQL 5\&.1\&.7\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: clear command.\" clear command: mysql\fBclear\fR,\fB\ec\fR.spClear the current input\&. Use this if you change your mind about executing the statement that you are entering\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: connect command.\" connect command: mysql\fBconnect [\fR\fB\fIdb_name\fR\fR\fB \fR\fB\fIhost_name\fR\fR\fB]]\fR,\fB\er [\fR\fB\fIdb_name\fR\fR\fB \fR\fB\fIhost_name\fR\fR\fB]]\fR.spReconnect to the server\&. The optional database name and host name arguments may be given to specify the default database or the host where the server is running\&. If omitted, the current values are used\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: delimiter command.\" delimiter command: mysql\fBdelimiter \fR\fB\fIstr\fR\fR,\fB\ed \fR\fB\fIstr\fR\fR.spChange the string that\fBmysql\fRinterprets as the separator between SQL statements\&. The default is the semicolon character (\(lq;\(rq)\&..spThe delimiter can be specified as an unquoted or quoted argument\&. Quoting can be done with either single quote (\') or douple quote (") characters\&. To include a quote within a quoted string, either quote the string with the other quote character or escape the quote with a backslash (\(lq\e\(rq) character\&. Backslash should be avoided outside of quoted strings because it is the escape character for MySQL\&. For an unquoted argument, the delmiter is read up to the first space or end of line\&. For a quoted argument, the delimiter is read up to the matching quote on the line\&..spWhen the delimiter recognized by\fBmysql\fRis set to something other than the default of\(lq;\(rq, instances of that character are sent to the server without interpretation\&. However, the server itself still interprets\(lq;\(rqas a statement delimiter and processes statements accordingly\&. This behavior on the server side comes into play for multiple\-statement execution (seeSection\ \&21.9.12, \(lqC API Support for Multiple Statement Execution\(rq), and for parsing the body of stored procedures and functions, triggers, and events (seeSection\ \&19.1, \(lqDefining Stored Programs\(rq)\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: edit command.\" edit command: mysql\fBedit\fR,\fB\ee\fR.spEdit the current input statement\&.\fBmysql\fRchecks the values of theEDITORandVISUALenvironment variables to determine which editor to use\&. The default editor is\fBvi\fRif neither variable is set\&..spThe\fBedit\fRcommand works only in Unix\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: ego command.\" ego command: mysql\fBego\fR,\fB\eG\fR.spSend the current statement to the server to be executed and display the result using vertical format\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: exit command.\" exit command: mysql\fBexit\fR,\fB\eq\fR.spExit\fBmysql\fR\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: go command.\" go command: mysql\fBgo\fR,\fB\eg\fR.spSend the current statement to the server to be executed\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: nopager command.\" nopager command: mysql\fBnopager\fR,\fB\en\fR.spDisable output paging\&. See the description for\fBpager\fR\&..spThe\fBnopager\fRcommand works only in Unix\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: notee command.\" notee command: mysql\fBnotee\fR,\fB\et\fR.spDisable output copying to the tee file\&. See the description for\fBtee\fR\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: nowarning command.\" nowarning command: mysql\fBnowarning\fR,\fB\ew\fR.spEnable display of warnings after each statement\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: pager command.\" pager command: mysql\fBpager [\fR\fB\fIcommand\fR\fR\fB]\fR,\fB\eP [\fR\fB\fIcommand\fR\fR\fB]\fR.spEnable output paging\&. By using the\fB\-\-pager\fRoption when you invoke\fBmysql\fR, it is possible to browse or search query results in interactive mode with Unix programs such as\fBless\fR,\fBmore\fR, or any other similar program\&. If you specify no value for the option,\fBmysql\fRchecks the value of thePAGERenvironment variable and sets the pager to that\&. Pager functionality works only in interactive mode\&..spOutput paging can be enabled interactively with the\fBpager\fRcommand and disabled with\fBnopager\fR\&. The command takes an optional argument; if given, the paging program is set to that\&. With no argument, the pager is set to the pager that was set on the command line, orstdoutif no pager was specified\&..spOutput paging works only in Unix because it uses thepopen()function, which does not exist on Windows\&. For Windows, the\fBtee\fRoption can be used instead to save query output, although it is not as convenient as\fBpager\fRfor browsing output in some situations\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: print command.\" print command: mysql\fBprint\fR,\fB\ep\fR.spPrint the current input statement without executing it\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: prompt command.\" prompt command: mysql\fBprompt [\fR\fB\fIstr\fR\fR\fB]\fR,\fB\eR [\fR\fB\fIstr\fR\fR\fB]\fR.spReconfigure the\fBmysql\fRprompt to the given string\&. The special character sequences that can be used in the prompt are described later in this section\&..spIf you specify thepromptcommand with no argument,\fBmysql\fRresets the prompt to the default ofmysql>\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: quit command.\" quit command: mysql\fBquit\fR,\fB\eq\fR.spExit\fBmysql\fR\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: rehash command.\" rehash command: mysql\fBrehash\fR,\fB\e#\fR.spRebuild the completion hash that enables database, table, and column name completion while you are entering statements\&. (See the description for the\fB\-\-auto\-rehash\fRoption\&.).RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: source command.\" source command: mysql\fBsource \fR\fB\fIfile_name\fR\fR,\fB\e\&. \fR\fB\fIfile_name\fR\fR.spRead the named file and executes the statements contained therein\&. On Windows, you can specify path name separators as/or\e\e\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: status command.\" status command: mysql\fBstatus\fR,\fB\es\fR.spProvide status information about the connection and the server you are using\&. If you are running in\fB\-\-safe\-updates\fRmode,statusalso prints the values for the\fBmysql\fRvariables that affect your queries\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: system command.\" system command: mysql\fBsystem \fR\fB\fIcommand\fR\fR,\fB\e! \fR\fB\fIcommand\fR\fR.spExecute the given command using your default command interpreter\&..spThe\fBsystem\fRcommand works only in Unix\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: tee command.\" tee command: mysql\fBtee [\fR\fB\fIfile_name\fR\fR\fB]\fR,\fB\eT [\fR\fB\fIfile_name\fR\fR\fB]\fR.spBy using the\fB\-\-tee\fRoption when you invoke\fBmysql\fR, you can log statements and their output\&. All the data displayed on the screen is appended into a given file\&. This can be very useful for debugging purposes also\&.\fBmysql\fRflushes results to the file after each statement, just before it prints its next prompt\&. Tee functionality works only in interactive mode\&..spYou can enable this feature interactively with the\fBtee\fRcommand\&. Without a parameter, the previous file is used\&. The\fBtee\fRfile can be disabled with the\fBnotee\fRcommand\&. Executing\fBtee\fRagain re\-enables logging\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: use command.\" use command: mysql\fBuse \fR\fB\fIdb_name\fR\fR,\fB\eu \fR\fB\fIdb_name\fR\fR.spUse\fIdb_name\fRas the default database\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}.\" mysql: warnings command.\" warnings command: mysql\fBwarnings\fR,\fB\eW\fR.spEnable display of warnings after each statement (if there are any)\&..RE.PPHere are a few tips about the\fBpager\fRcommand:.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}You can use it to write to a file and the results go only to the file:.sp.if n \{\.RS 4.\}.nfmysql> \fBpager cat > /tmp/log\&.txt\fR.fi.if n \{\.RE.\}.spYou can also pass any options for the program that you want to use as your pager:.sp.if n \{\.RS 4.\}.nfmysql> \fBpager less \-n \-i \-S\fR.fi.if n \{\.RE.\}.RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}In the preceding example, note the\fB\-S\fRoption\&. You may find it very useful for browsing wide query results\&. Sometimes a very wide result set is difficult to read on the screen\&. The\fB\-S\fRoption to\fBless\fRcan make the result set much more readable because you can scroll it horizontally using the left\-arrow and right\-arrow keys\&. You can also use\fB\-S\fRinteractively within\fBless\fRto switch the horizontal\-browse mode on and off\&. For more information, read the\fBless\fRmanual page:.sp.if n \{\.RS 4.\}.nfshell> \fBman less\fR.fi.if n \{\.RE.\}.RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}The\fB\-F\fRand\fB\-X\fRoptions may be used with\fBless\fRto cause it to exit if output fits on one screen, which is convenient when no scrolling is necessary:.sp.if n \{\.RS 4.\}.nfmysql> \fBpager less \-n \-i \-S \-F \-X\fR.fi.if n \{\.RE.\}.RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}You can specify very complex pager commands for handling query output:.sp.if n \{\.RS 4.\}.nfmysql> \fBpager cat | tee /dr1/tmp/res\&.txt \e\fR \fB| tee /dr2/tmp/res2\&.txt | less \-n \-i \-S\fR.fi.if n \{\.RE.\}.spIn this example, the command would send query results to two files in two different directories on two different file systems mounted on/dr1and/dr2, yet still display the results onscreen via\fBless\fR\&..RE.PPYou can also combine the\fBtee\fRand\fBpager\fRfunctions\&. Have a\fBtee\fRfile enabled and\fBpager\fRset to\fBless\fR, and you are able to browse the results using the\fBless\fRprogram and still have everything appended into a file the same time\&. The difference between the Unix\fBtee\fRused with the\fBpager\fRcommand and the\fBmysql\fRbuilt\-in\fBtee\fRcommand is that the built\-in\fBtee\fRworks even if you do not have the Unix\fBtee\fRavailable\&. The built\-in\fBtee\fRalso logs everything that is printed on the screen, whereas the Unix\fBtee\fRused with\fBpager\fRdoes not log quite that much\&. Additionally,\fBtee\fRfile logging can be turned on and off interactively from within\fBmysql\fR\&. This is useful when you want to log some queries to a file, but not others\&..\" mysql prompt command.PPThe\fBprompt\fRcommand reconfigures the defaultmysql>prompt\&. The string for defining the prompt can contain the following special sequences\&..TSallbox tab(:);l ll ll ll ll ll ll ll ll ll ll ll ll ll ll ll ll ll ll ll ll ll ll ll ll ll ll ll ll l.T{\fBOption\fRT}:T{\fBDescription\fRT}T{\ecT}:T{A counter that increments for each statement you issueT}T{\eDT}:T{The full current dateT}T{\edT}:T{The default databaseT}T{\ehT}:T{The server hostT}T{\elT}:T{The current delimiter (new in 5\&.1\&.12)T}T{\emT}:T{Minutes of the current timeT}T{\enT}:T{A newline characterT}T{\eOT}:T{The current month in three\-letter format (Jan, Feb, \&...)T}T{\eoT}:T{The current month in numeric formatT}T{\ePT}:T{am/pmT}T{\epT}:T{The current TCP/IP port or socket fileT}T{\eRT}:T{The current time, in 24\-hour military time (0\(en23)T}T{\erT}:T{The current time, standard 12\-hour time (1\(en12)T}T{\eST}:T{SemicolonT}T{\esT}:T{Seconds of the current timeT}T{\etT}:T{A tab characterT}T{\eUT}:T{.PPYour full\fIuser_name\fR@\fIhost_name\fRaccount nameT}T{\euT}:T{Your user nameT}T{\evT}:T{The server versionT}T{\ewT}:T{The current day of the week in three\-letter format (Mon, Tue, \&...)T}T{\eYT}:T{The current year, four digitsT}T{\eyT}:T{The current year, two digitsT}T{\e_T}:T{A spaceT}T{\e\ \&T}:T{A space (a space follows the backslash)T}T{\e\'T}:T{Single quoteT}T{\e"T}:T{Double quoteT}T{\e\eT}:T{A literal \(lq\e\(rq backslash characterT}T{\e\fIx\fRT}:T{.PP\fIx\fR, for any\(lq\fIx\fR\(rqnot listed aboveT}.TE.sp 1.PPYou can set the prompt in several ways:.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}\fIUse an environment variable\&.\fRYou can set theMYSQL_PS1environment variable to a prompt string\&. For example:.sp.if n \{\.RS 4.\}.nfshell> \fBexport MYSQL_PS1="(\eu@\eh) [\ed]> "\fR.fi.if n \{\.RE.\}.RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}\fIUse a command\-line option\&.\fRYou can set the\fB\-\-prompt\fRoption on the command line to\fBmysql\fR\&. For example:.sp.if n \{\.RS 4.\}.nfshell> \fBmysql \-\-prompt="(\eu@\eh) [\ed]> "\fR(user@host) [database]>.fi.if n \{\.RE.\}.RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}\fIUse an option file\&.\fRYou can set thepromptoption in the[mysql]group of any MySQL option file, such as/etc/my\&.cnfor the\&.my\&.cnffile in your home directory\&. For example:.sp.if n \{\.RS 4.\}.nf[mysql]prompt=(\e\eu@\e\eh) [\e\ed]>\e\e_.fi.if n \{\.RE.\}.spIn this example, note that the backslashes are doubled\&. If you set the prompt using thepromptoption in an option file, it is advisable to double the backslashes when using the special prompt options\&. There is some overlap in the set of allowable prompt options and the set of special escape sequences that are recognized in option files\&. (The rules for escape sequences in option files are listed inSection\ \&4.2.3.3, \(lqUsing Option Files\(rq\&.) The overlap may cause you problems if you use single backslashes\&. For example,\esis interpreted as a space rather than as the current seconds value\&. The following example shows how to define a prompt within an option file to include the current time inHH:MM:SS>format:.sp.if n \{\.RS 4.\}.nf[mysql]prompt="\e\er:\e\em:\e\es> ".fi.if n \{\.RE.\}.RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}\fISet the prompt interactively\&.\fRYou can change your prompt interactively by using theprompt(or\eR) command\&. For example:.sp.if n \{\.RS 4.\}.nfmysql> \fBprompt (\eu@\eh) [\ed]>\e_\fRPROMPT set to \'(\eu@\eh) [\ed]>\e_\'(\fIuser\fR@\fIhost\fR) [\fIdatabase\fR]>(\fIuser\fR@\fIhost\fR) [\fIdatabase\fR]> promptReturning to default PROMPT of mysql>mysql>.fi.if n \{\.RE.\}.RE.SH "MYSQL SERVER-SIDE HELP".sp.if n \{\.RS 4.\}.nfmysql> \fBhelp \fR\fB\fIsearch_string\fR\fR.fi.if n \{\.RE.\}.PPIf you provide an argument to thehelpcommand,\fBmysql\fRuses it as a search string to access server\-side help from the contents of the MySQL Reference Manual\&. The proper operation of this command requires that the help tables in themysqldatabase be initialized with help topic information (seeSection\ \&5.1.9, \(lqServer-Side Help\(rq)\&..PPIf there is no match for the search string, the search fails:.sp.if n \{\.RS 4.\}.nfmysql> \fBhelp me\fRNothing foundPlease try to run \'help contents\' for a list of all accessible topics.fi.if n \{\.RE.\}.PPUse\fBhelp contents\fRto see a list of the help categories:.sp.if n \{\.RS 4.\}.nfmysql> \fBhelp contents\fRYou asked for help about help category: "Contents"For more information, type \'help <item>\', where <item> is one of thefollowing categories: Account Management Administration Data Definition Data Manipulation Data Types Functions Functions and Modifiers for Use with GROUP BY Geographic Features Language Structure Plugins Storage Engines Stored Routines Table Maintenance Transactions Triggers.fi.if n \{\.RE.\}.PPIf the search string matches multiple items,\fBmysql\fRshows a list of matching topics:.sp.if n \{\.RS 4.\}.nfmysql> \fBhelp logs\fRMany help items for your request exist\&.To make a more specific request, please type \'help <item>\',where <item> is one of the following topics: SHOW SHOW BINARY LOGS SHOW ENGINE SHOW LOGS.fi.if n \{\.RE.\}.PPUse a topic as the search string to see the help entry for that topic:.sp.if n \{\.RS 4.\}.nfmysql> \fBhelp show binary logs\fRName: \'SHOW BINARY LOGS\'Description:Syntax:SHOW BINARY LOGSSHOW MASTER LOGSLists the binary log files on the server\&. This statement is used aspart of the procedure described in [purge\-binary\-logs], that shows howto determine which logs can be purged\&.mysql> SHOW BINARY LOGS;+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+| Log_name | File_size |+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+| binlog\&.000015 | 724935 || binlog\&.000016 | 733481 |+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+.fi.if n \{\.RE.\}.SH "EXECUTING SQL STATEMENTS FROM A TEXT FILE".\" executing SQL statements from text files.\" importing: data.\" data: importing.\" files: text.\" text files: importing.\" source (mysql client command).\" \. (mysql client command).\" mysql source (command for reading from text files).\" mysql \. (command for reading from text files).PPThe\fBmysql\fRclient typically is used interactively, like this:.sp.if n \{\.RS 4.\}.nfshell> \fBmysql \fR\fB\fIdb_name\fR\fR.fi.if n \{\.RE.\}.PPHowever, it is also possible to put your SQL statements in a file and then tell\fBmysql\fRto read its input from that file\&. To do so, create a text file\fItext_file\fRthat contains the statements you wish to execute\&. Then invoke\fBmysql\fRas shown here:.sp.if n \{\.RS 4.\}.nfshell> \fBmysql \fR\fB\fIdb_name\fR\fR\fB < \fR\fB\fItext_file\fR\fR.fi.if n \{\.RE.\}.PPIf you place aUSE \fIdb_name\fRstatement as the first statement in the file, it is unnecessary to specify the database name on the command line:.sp.if n \{\.RS 4.\}.nfshell> \fBmysql < text_file\fR.fi.if n \{\.RE.\}.PPIf you are already running\fBmysql\fR, you can execute an SQL script file using thesourcecommand or\e\&.command:.sp.if n \{\.RS 4.\}.nfmysql> \fBsource \fR\fB\fIfile_name\fR\fRmysql> \fB\e\&. \fR\fB\fIfile_name\fR\fR.fi.if n \{\.RE.\}.PPSometimes you may want your script to display progress information to the user\&. For this you can insert statements like this:.sp.if n \{\.RS 4.\}.nfSELECT \'<info_to_display>\' AS \' \';.fi.if n \{\.RE.\}.PPThe statement shown outputs<info_to_display>\&..PPYou can also invoke\fBmysql\fRwith the\fB\-\-verbose\fRoption, which causes each statement to be displayed before the result that it produces\&..PPAs of MySQL 5\&.1\&.23,\fBmysql\fRignores Unicode byte order mark (BOM) characters at the beginning of input files\&. Previously, it read them and sent them to the server, resulting in a syntax error\&. Presence of a BOM does not cause\fBmysql\fRto change its default character set\&. To do that, invoke\fBmysql\fRwith an option such as\fB\-\-default\-character\-set=utf8\fR\&..PPFor more information about batch mode, seeSection\ \&3.5, \(lqUsing mysql in Batch Mode\(rq\&..SH "MYSQL TIPS".PPThis section describes some techniques that can help you use\fBmysql\fRmore effectively\&..SS "Displaying Query Results Vertically".PPSome query results are much more readable when displayed vertically, instead of in the usual horizontal table format\&. Queries can be displayed vertically by terminating the query with \eG instead of a semicolon\&. For example, longer text values that include newlines often are much easier to read with vertical output:.sp.if n \{\.RS 4.\}.nfmysql> \fBSELECT * FROM mails WHERE LENGTH(txt) < 300 LIMIT 300,1\eG\fR*************************** 1\&. row *************************** msg_nro: 3068 date: 2000\-03\-01 23:29:50time_zone: +0200mail_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 familiarThimble> with UTF\-8 or Unicode? Otherwise, I\'ll put this on myThimble> TODO list and see what happens\&.Yes, please do that\&.Regards,Monty file: inbox\-jani\-1 hash: 1904029441 row in set (0\&.09 sec).fi.if n \{\.RE.\}.SS "Using the \-\-safe\-updates Option".\" safe-updates option.PPFor beginners, a useful startup option is\fB\-\-safe\-updates\fR(or\fB\-\-i\-am\-a\-dummy\fR, which has the same effect)\&. It is helpful for cases when you might have issued aDELETE FROM \fItbl_name\fRstatement but forgotten theWHEREclause\&. Normally, such a statement deletes all rows from the table\&. With\fB\-\-safe\-updates\fR, you can delete rows only by specifying the key values that identify them\&. This helps prevent accidents\&..PPWhen you use the\fB\-\-safe\-updates\fRoption,\fBmysql\fRissues the following statement when it connects to the MySQL server:.sp.if n \{\.RS 4.\}.nfSET sql_safe_updates=1, sql_select_limit=1000, sql_max_join_size=1000000;.fi.if n \{\.RE.\}.PPSeeSection\ \&5.1.5, \(lqSession System Variables\(rq\&..PPTheSETstatement has the following effects:.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}You are not allowed to execute anUPDATEorDELETEstatement unless you specify a key constraint in theWHEREclause or provide aLIMITclause (or both)\&. For example:.sp.if n \{\.RS 4.\}.nfUPDATE \fItbl_name\fR SET \fInot_key_column\fR=\fIval\fR WHERE \fIkey_column\fR=\fIval\fR;UPDATE \fItbl_name\fR SET \fInot_key_column\fR=\fIval\fR LIMIT 1;.fi.if n \{\.RE.\}.RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}The server limits all largeSELECTresults to 1,000 rows unless the statement includes aLIMITclause\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}The server aborts multiple\-tableSELECTstatements that probably need to examine more than 1,000,000 row combinations\&..RE.PPTo specify limits different from 1,000 and 1,000,000, you can override the defaults by using the\fB\-\-select_limit\fRand\fB\-\-max_join_size\fRoptions:.sp.if n \{\.RS 4.\}.nfshell> \fBmysql \-\-safe\-updates \-\-select_limit=500 \-\-max_join_size=10000\fR.fi.if n \{\.RE.\}.SS "Disabling mysql Auto\-Reconnect".PPIf the\fBmysql\fRclient loses its connection to the server while sending a statement, it immediately and automatically tries to reconnect once to the server and send the statement again\&. However, even if\fBmysql\fRsucceeds in reconnecting, your first connection has ended and all your previous session objects and settings are lost: temporary tables, the autocommit mode, and user\-defined and session variables\&. Also, any current transaction rolls back\&. This behavior may be dangerous for you, as in the following example where the server was shut down and restarted between the first and second statements without you knowing it:.sp.if n \{\.RS 4.\}.nfmysql> \fBSET @a=1;\fRQuery OK, 0 rows affected (0\&.05 sec)mysql> \fBINSERT INTO t VALUES(@a);\fRERROR 2006: MySQL server has gone awayNo connection\&. Trying to reconnect\&.\&.\&.Connection id: 1Current database: testQuery OK, 1 row affected (1\&.30 sec)mysql> \fBSELECT * FROM t;\fR+\-\-\-\-\-\-+| a |+\-\-\-\-\-\-+| NULL |+\-\-\-\-\-\-+1 row in set (0\&.05 sec).fi.if n \{\.RE.\}.PPThe@auser variable has been lost with the connection, and after the reconnection it is undefined\&. If it is important to have\fBmysql\fRterminate with an error if the connection has been lost, you can start the\fBmysql\fRclient with the\fB\-\-skip\-reconnect\fRoption\&..PPFor more information about auto\-reconnect and its effect on state information when a reconnection occurs, seeSection\ \&21.9.11, \(lqControlling Automatic Reconnection Behavior\(rq\&..SH "COPYRIGHT".br.PPCopyright 2007-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc..PPThis documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License..PPThis documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details..PPYou should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see http://www.gnu.org/licenses/..sp.SH "NOTES".IP " 1." 4Bug#25946.RS 4\%http://bugs.mysql.com/bug.php?id=25946.RE.SH "SEE ALSO"For more information, please refer to the MySQL Reference Manual,which may already be installed locally and which is also availableonline at http://dev.mysql.com/doc/..SH AUTHORSun Microsystems, Inc. (http://www.mysql.com/).
|