1MYSQL(1)                     MySQL Database System                    MYSQL(1)
2
3
4

NAME

6       mysql - the MySQL command-line client
7

SYNOPSIS

9       mysql [options] db_name
10

DESCRIPTION

12       mysql is a simple SQL shell with input line editing capabilities. It
13       supports interactive and noninteractive use. When used interactively,
14       query results are presented in an ASCII-table format. When used
15       noninteractively (for example, as a filter), the result is presented in
16       tab-separated format. The output format can be changed using command
17       options.
18
19       If you have problems due to insufficient memory for large result sets,
20       use the --quick option. This forces mysql to retrieve results from the
21       server a row at a time rather than retrieving the entire result set and
22       buffering it in memory before displaying it. This is done by returning
23       the result set using the mysql_use_result() C API function in the
24       client/server library rather than mysql_store_result().
25
26           Note
27           Alternatively, MySQL Shell offers access to the X DevAPI. For
28           details, see MySQL Shell 8.0[1].
29
30       Using mysql is very easy. Invoke it from the prompt of your command
31       interpreter as follows:
32
33           mysql db_name
34
35       Or:
36
37           mysql --user=user_name --password db_name
38
39       In this case, you'll need to enter your password in response to the
40       prompt that mysql displays:
41
42           Enter password: your_password
43
44       Then type an SQL statement, end it with ;, \g, or \G and press Enter.
45
46       Typing Control+C interrupts the current statement if there is one, or
47       cancels any partial input line otherwise.
48
49       You can execute SQL statements in a script file (batch file) like this:
50
51           mysql db_name < script.sql > output.tab
52
53       On Unix, the mysql client logs statements executed interactively to a
54       history file. See the section called “MYSQL CLIENT LOGGING”.
55

MYSQL CLIENT OPTIONS

57       mysql supports the following options, which can be specified on the
58       command line or in the [mysql] and [client] groups of an option file.
59       For information about option files used by MySQL programs, see
60       Section 4.2.2.2, “Using Option Files”.
61
62--help, -?  Display a help message and exit.
63
64--auto-rehash Enable automatic rehashing. This option is on by
65           default, which enables database, table, and column name completion.
66           Use --disable-auto-rehash to disable rehashing. That causes mysql
67           to start faster, but you must issue the rehash command or its \#
68           shortcut if you want to use name completion.
69
70           To complete a name, enter the first part and press Tab. If the name
71           is unambiguous, mysql completes it. Otherwise, you can press Tab
72           again to see the possible names that begin with what you have typed
73           so far. Completion does not occur if there is no default database.
74
75               Note
76               This feature requires a MySQL client that is compiled with the
77               readline library. Typically, the readline library is not
78               available on Windows.
79
80--auto-vertical-output Cause result sets to be displayed vertically
81           if they are too wide for the current window, and using normal
82           tabular format otherwise. (This applies to statements terminated by
83           ; or \G.)
84
85--batch, -B Print results using tab as the column separator, with
86           each row on a new line. With this option, mysql does not use the
87           history file.
88
89           Batch mode results in nontabular output format and escaping of
90           special characters. Escaping may be disabled by using raw mode; see
91           the description for the --raw option.
92
93--binary-as-hex When this option is given, mysql displays binary
94           data using hexadecimal notation (0xvalue). This occurs whether the
95           overall output display format is tabular, vertical, HTML, or XML.
96
97           --binary-as-hex when enabled affects display of all binary strings,
98           including those returned by functions such as CHAR() and UNHEX().
99           The following example demonstrates this using the ASCII code for A
100           (65 decimal, 41 hexadecimal):
101
102--binary-as-hex disabled:
103
104                   mysql> SELECT CHAR(0x41), UNHEX('41');
105                   +------------+-------------+
106                   | CHAR(0x41) | UNHEX('41') |
107                   +------------+-------------+
108                   | A          | A           |
109                   +------------+-------------+
110
111--binary-as-hex enabled:
112
113                   mysql> SELECT CHAR(0x41), UNHEX('41');
114                   +------------------------+--------------------------+
115                   | CHAR(0x41)             | UNHEX('41')              |
116                   +------------------------+--------------------------+
117                   | 0x41                   | 0x41                     |
118                   +------------------------+--------------------------+
119
120           To write a binary string expression so that it displays as a
121           character string regardless of whether --binary-as-hex is enabled,
122           use these techniques:
123
124           •   The CHAR() function has a USING charset clause:
125
126                   mysql> SELECT CHAR(0x41 USING utf8mb4);
127                   +--------------------------+
128                   | CHAR(0x41 USING utf8mb4) |
129                   +--------------------------+
130                   | A                        |
131                   +--------------------------+
132
133           •   More generally, use CONVERT() to convert an expression to a
134               given character set:
135
136                   mysql> SELECT CONVERT(UNHEX('41') USING utf8mb4);
137                   +------------------------------------+
138                   | CONVERT(UNHEX('41') USING utf8mb4) |
139                   +------------------------------------+
140                   | A                                  |
141                   +------------------------------------+
142
143           As of MySQL 8.0.19, when mysql operates in interactive mode, this
144           option is enabled by default. In addition, output from the status
145           (or \s) command includes this line when the option is enabled
146           implicitly or explicitly:
147
148               Binary data as: Hexadecimal
149
150           To disable hexadecimal notation, use --skip-binary-as-hex
151
152--binary-mode This option helps when processing mysqlbinlog output
153           that may contain BLOB values. By default, mysql translates \r\n in
154           statement strings to \n and interprets \0 as the statement
155           terminator.  --binary-mode disables both features. It also disables
156           all mysql commands except charset and delimiter in noninteractive
157           mode (for input piped to mysql or loaded using the source command).
158
159--bind-address=ip_address On a computer having multiple network
160           interfaces, use this option to select which interface to use for
161           connecting to the MySQL server.
162
163--character-sets-dir=dir_name The directory where character sets
164           are installed. See Section 10.15, “Character Set Configuration”.
165
166--column-names Write column names in results.
167
168--column-type-info Display result set metadata. This information
169           corresponds to the contents of C API MYSQL_FIELD data structures.
170           See C API Basic Data Structures[2].
171
172--comments, -c Whether to strip or preserve comments in statements
173           sent to the server. The default is --skip-comments (strip
174           comments), enable with --comments (preserve comments).
175
176               Note
177               The mysql client always passes optimizer hints to the server,
178               regardless of whether this option is given.
179
180               Comment stripping is deprecated. Expect this feature and the
181               options to control it to be removed in a future MySQL release.
182
183--compress, -C Compress all information sent between the client and
184           the server if possible. See Section 4.2.8, “Connection Compression
185           Control”.
186
187           As of MySQL 8.0.18, this option is deprecated. Expect it to be
188           removed in a future version of MySQL. See the section called
189           “Configuring Legacy Connection Compression”.
190
191--compression-algorithms=value The permitted compression algorithms
192           for connections to the server. The available algorithms are the
193           same as for the protocol_compression_algorithms system variable.
194           The default value is uncompressed.
195
196           For more information, see Section 4.2.8, “Connection Compression
197           Control”.
198
199           This option was added in MySQL 8.0.18.
200
201--connect-expired-password Indicate to the server that the client
202           can handle sandbox mode if the account used to connect has an
203           expired password. This can be useful for noninteractive invocations
204           of mysql because normally the server disconnects noninteractive
205           clients that attempt to connect using an account with an expired
206           password. (See Section 6.2.16, “Server Handling of Expired
207           Passwords”.)
208
209--connect-timeout=value The number of seconds before connection
210           timeout. (Default value is 0.)
211
212--database=db_name, -D db_name The database to use. This is useful
213           primarily in an option file.
214
215--debug[=debug_options], -# [debug_options] Write a debugging log.
216           A typical debug_options string is d:t:o,file_name. The default is
217           d:t:o,/tmp/mysql.trace.
218
219           This option is available only if MySQL was built using WITH_DEBUG.
220           MySQL release binaries provided by Oracle are not built using this
221           option.
222
223--debug-check Print some debugging information when the program
224           exits.
225
226           This option is available only if MySQL was built using WITH_DEBUG.
227           MySQL release binaries provided by Oracle are not built using this
228           option.
229
230--debug-info, -T Print debugging information and memory and CPU
231           usage statistics when the program exits.
232
233           This option is available only if MySQL was built using WITH_DEBUG.
234           MySQL release binaries provided by Oracle are not built using this
235           option.
236
237--default-auth=plugin A hint about which client-side authentication
238           plugin to use. See Section 6.2.17, “Pluggable Authentication”.
239
240--default-character-set=charset_name Use charset_name as the
241           default character set for the client and connection.
242
243           This option can be useful if the operating system uses one
244           character set and the mysql client by default uses another. In this
245           case, output may be formatted incorrectly. You can usually fix such
246           issues by using this option to force the client to use the system
247           character set instead.
248
249           For more information, see Section 10.4, “Connection Character Sets
250           and Collations”, and Section 10.15, “Character Set Configuration”.
251
252--defaults-extra-file=file_name Read this option file after the
253           global option file but (on Unix) before the user option file. If
254           the file does not exist or is otherwise inaccessible, an error
255           occurs. If file_name is not an absolute path name, it is
256           interpreted relative to the current directory.
257
258           For additional information about this and other option-file
259           options, see Section 4.2.2.3, “Command-Line Options that Affect
260           Option-File Handling”.
261
262--defaults-file=file_name Use only the given option file. If the
263           file does not exist or is otherwise inaccessible, an error occurs.
264           If file_name is not an absolute path name, it is interpreted
265           relative to the current directory.
266
267           Exception: Even with --defaults-file, client programs read
268           .mylogin.cnf.
269
270           For additional information about this and other option-file
271           options, see Section 4.2.2.3, “Command-Line Options that Affect
272           Option-File Handling”.
273
274--defaults-group-suffix=str Read not only the usual option groups,
275           but also groups with the usual names and a suffix of str. For
276           example, mysql normally reads the [client] and [mysql] groups. If
277           this option is given as --defaults-group-suffix=_other, mysql also
278           reads the [client_other] and [mysql_other] groups.
279
280           For additional information about this and other option-file
281           options, see Section 4.2.2.3, “Command-Line Options that Affect
282           Option-File Handling”.
283
284--delimiter=str Set the statement delimiter. The default is the
285           semicolon character (;).
286
287--disable-named-commands Disable named commands. Use the \* form
288           only, or use named commands only at the beginning of a line ending
289           with a semicolon (;).  mysql starts with this option enabled by
290           default. However, even with this option, long-format commands still
291           work from the first line. See the section called “MYSQL CLIENT
292           COMMANDS”.
293
294--dns-srv-name=name Specifies the name of a DNS SRV record that
295           determines the candidate hosts to use for establishing a connection
296           to a MySQL server. For information about DNS SRV support in MySQL,
297           see Section 4.2.6, “Connecting to the Server Using DNS SRV
298           Records”.
299
300           Suppose that DNS is configured with this SRV information for the
301           example.com domain:
302
303               Name                     TTL   Class   Priority Weight Port Target
304               _mysql._tcp.example.com. 86400 IN SRV  0        5      3306 host1.example.com
305               _mysql._tcp.example.com. 86400 IN SRV  0        10     3306 host2.example.com
306               _mysql._tcp.example.com. 86400 IN SRV  10       5      3306 host3.example.com
307               _mysql._tcp.example.com. 86400 IN SRV  20       5      3306 host4.example.com
308
309           To use that DNS SRV record, invoke mysql like this:
310
311               mysql --dns-srv-name=_mysql._tcp.example.com
312
313           mysql then attempts a connection to each server in the group until
314           a successful connection is established. A failure to connect occurs
315           only if a connection cannot be established to any of the servers.
316           The priority and weight values in the DNS SRV record determine the
317           order in which servers should be tried.
318
319           When invoked with --dns-srv-name, mysql attempts to establish TCP
320           connections only.
321
322           The --dns-srv-name option takes precedence over the --host option
323           if both are given.  --dns-srv-name causes connection establishment
324           to use the mysql_real_connect_dns_srv() C API function rather than
325           mysql_real_connect(). However, if the connect command is
326           subsequently used at runtime and specifies a host name argument,
327           that host name takes precedence over any --dns-srv-name option
328           given at mysql startup to specify a DNS SRV record.
329
330           This option was added in MySQL 8.0.22.
331
332--enable-cleartext-plugin Enable the mysql_clear_password cleartext
333           authentication plugin. (See Section 6.4.1.4, “Client-Side Cleartext
334           Pluggable Authentication”.)
335
336--execute=statement, -e statement Execute the statement and quit.
337           The default output format is like that produced with --batch. See
338           Section 4.2.2.1, “Using Options on the Command Line”, for some
339           examples. With this option, mysql does not use the history file.
340
341--fido-register-factor=value The factor or factors for which FIDO
342           device registration must be performed. This option value must be a
343           single value, or two values separated by commas. Each value must be
344           2 or 3, so the permitted option values are '2', '3', '2,3' and
345           '3,2'.
346
347           For example, an account that requires registration for a 3rd
348           authentication factor invokes the mysql client as follows:
349
350               mysql --user=user_name --fido-register-factor=3
351
352           An account that requires registration for a 2nd and 3rd
353           authentication factor invokes the mysql client as follows:
354
355               mysql --user=user_name --fido-register-factor=2,3
356
357           If registration is successful, a connection is established. If
358           there is an authentication factor with a pending registration, a
359           connection is placed into pending registration mode when attempting
360           to connect to the server. In this case, disconnect and reconnect
361           with the correct --fido-register-factor value to complete the
362           registration.
363
364           Registration is a two step process comprising initiate registration
365           and finish registration steps. The initiate registration step
366           executes this statement:
367
368               ALTER USER user factor INITIATE REGISTRATION
369
370           The statement returns a result set containing a 32 byte challenge,
371           the user name, and the relying party ID (see
372           authentication_fido_rp_id).
373
374           The finish registration step executes this statement:
375
376               ALTER USER user factor FINISH REGISTRATION SET CHALLENGE_RESPONSE AS 'auth_string'
377
378           The statement completes the registration and sends the following
379           information to the server as part of the auth_string: authenticator
380           data, an optional attestation certificate in X.509 format, and a
381           signature.
382
383           The initiate and registration steps must be performed in a single
384           connection, as the challenge received by the client during the
385           initiate step is saved to the client connection handler.
386           Registration would fail if the registration step was performed by a
387           different connection. The --fido-register-factor option executes
388           both the initiate and registration steps, which avoids the failure
389           scenario described above and prevents having to execute the ALTER
390           USER initiate and registration statements manually.
391
392           The --fido-register-factor option is only available for the mysql
393           client and MySQL Shell. Other MySQL client programs do not support
394           it.
395
396           For related information, see the section called “Using FIDO
397           Authentication”.
398
399--force, -f Continue even if an SQL error occurs.
400
401--get-server-public-key Request from the server the public key
402           required for RSA key pair-based password exchange. This option
403           applies to clients that authenticate with the caching_sha2_password
404           authentication plugin. For that plugin, the server does not send
405           the public key unless requested. This option is ignored for
406           accounts that do not authenticate with that plugin. It is also
407           ignored if RSA-based password exchange is not used, as is the case
408           when the client connects to the server using a secure connection.
409
410           If --server-public-key-path=file_name is given and specifies a
411           valid public key file, it takes precedence over
412           --get-server-public-key.
413
414           For information about the caching_sha2_password plugin, see
415           Section 6.4.1.2, “Caching SHA-2 Pluggable Authentication”.
416
417--histignore A list of one or more colon-separated patterns
418           specifying statements to ignore for logging purposes. These
419           patterns are added to the default pattern list
420           ("*IDENTIFIED*:*PASSWORD*"). The value specified for this option
421           affects logging of statements written to the history file, and to
422           syslog if the --syslog option is given. For more information, see
423           the section called “MYSQL CLIENT LOGGING”.
424
425--host=host_name, -h host_name Connect to the MySQL server on the
426           given host.
427
428           The --dns-srv-name option takes precedence over the --host option
429           if both are given.  --dns-srv-name causes connection establishment
430           to use the mysql_real_connect_dns_srv() C API function rather than
431           mysql_real_connect(). However, if the connect command is
432           subsequently used at runtime and specifies a host name argument,
433           that host name takes precedence over any --dns-srv-name option
434           given at mysql startup to specify a DNS SRV record.
435
436--html, -H Produce HTML output.
437
438--ignore-spaces, -i Ignore spaces after function names. The effect
439           of this is described in the discussion for the IGNORE_SPACE SQL
440           mode (see Section 5.1.11, “Server SQL Modes”).
441
442--init-command=str SQL statement to execute after connecting to the
443           server. If auto-reconnect is enabled, the statement is executed
444           again after reconnection occurs.
445
446--line-numbers Write line numbers for errors. Disable this with
447           --skip-line-numbers.
448
449--load-data-local-dir=dir_name This option affects the client-side
450           LOCAL capability for LOAD DATA operations. It specifies the
451           directory in which files named in LOAD DATA LOCAL statements must
452           be located. The effect of --load-data-local-dir depends on whether
453           LOCAL data loading is enabled or disabled:
454
455           •   If LOCAL data loading is enabled, either by default in the
456               MySQL client library or by specifying --local-infile[=1], the
457               --load-data-local-dir option is ignored.
458
459           •   If LOCAL data loading is disabled, either by default in the
460               MySQL client library or by specifying --local-infile=0, the
461               --load-data-local-dir option applies.
462
463           When --load-data-local-dir applies, the option value designates the
464           directory in which local data files must be located. Comparison of
465           the directory path name and the path name of files to be loaded is
466           case-sensitive regardless of the case sensitivity of the underlying
467           file system. If the option value is the empty string, it names no
468           directory, with the result that no files are permitted for local
469           data loading.
470
471           For example, to explicitly disable local data loading except for
472           files located in the /my/local/data directory, invoke mysql like
473           this:
474
475               mysql --local-infile=0 --load-data-local-dir=/my/local/data
476
477           When both --local-infile and --load-data-local-dir are given, the
478           order in which they are given does not matter.
479
480           Successful use of LOCAL load operations within mysql also requires
481           that the server permits local loading; see Section 6.1.6, “Security
482           Considerations for LOAD DATA LOCAL”
483
484           The --load-data-local-dir option was added in MySQL 8.0.21.
485
486--local-infile[={0|1}] By default, LOCAL capability for LOAD DATA
487           is determined by the default compiled into the MySQL client
488           library. To enable or disable LOCAL data loading explicitly, use
489           the --local-infile option. When given with no value, the option
490           enables LOCAL data loading. When given as --local-infile=0 or
491           --local-infile=1, the option disables or enables LOCAL data
492           loading.
493
494           If LOCAL capability is disabled, the --load-data-local-dir option
495           can be used to permit restricted local loading of files located in
496           a designated directory.
497
498           Successful use of LOCAL load operations within mysql also requires
499           that the server permits local loading; see Section 6.1.6, “Security
500           Considerations for LOAD DATA LOCAL”
501
502--login-path=name Read options from the named login path in the
503           .mylogin.cnf login path file. A “login path” is an option group
504           containing options that specify which MySQL server to connect to
505           and which account to authenticate as. To create or modify a login
506           path file, use the mysql_config_editor utility. See
507           mysql_config_editor(1).
508
509           For additional information about this and other option-file
510           options, see Section 4.2.2.3, “Command-Line Options that Affect
511           Option-File Handling”.
512
513--max-allowed-packet=value The maximum size of the buffer for
514           client/server communication. The default is 16MB, the maximum is
515           1GB.
516
517--max-join-size=value The automatic limit for rows in a join when
518           using --safe-updates. (Default value is 1,000,000.)
519
520--named-commands, -G Enable named mysql commands. Long-format
521           commands are permitted, not just short-format commands. For
522           example, quit and \q both are recognized. Use --skip-named-commands
523           to disable named commands. See the section called “MYSQL CLIENT
524           COMMANDS”.
525
526--net-buffer-length=value The buffer size for TCP/IP and socket
527           communication. (Default value is 16KB.)
528
529--network-namespace=name The network namespace to use for TCP/IP
530           connections. If omitted, the connection uses the default (global)
531           namespace. For information about network namespaces, see
532           Section 5.1.14, “Network Namespace Support”.
533
534           This option was added in MySQL 8.0.22. It is available only on
535           platforms that implement network namespace support.
536
537--no-auto-rehash, -A This has the same effect as
538           --skip-auto-rehash. See the description for --auto-rehash.
539
540--no-beep, -b Do not beep when errors occur.
541
542--no-defaults Do not read any option files. If program startup
543           fails due to reading unknown options from an option file,
544           --no-defaults can be used to prevent them from being read.
545
546           The exception is that the .mylogin.cnf file is read in all cases,
547           if it exists. This permits passwords to be specified in a safer way
548           than on the command line even when --no-defaults is used. To create
549           .mylogin.cnf, use the mysql_config_editor utility. See
550           mysql_config_editor(1).
551
552           For additional information about this and other option-file
553           options, see Section 4.2.2.3, “Command-Line Options that Affect
554           Option-File Handling”.
555
556--one-database, -o Ignore statements except those that occur while
557           the default database is the one named on the command line. This
558           option is rudimentary and should be used with care. Statement
559           filtering is based only on USE statements.
560
561           Initially, mysql executes statements in the input because
562           specifying a database db_name on the command line is equivalent to
563           inserting USE db_name at the beginning of the input. Then, for each
564           USE statement encountered, mysql accepts or rejects following
565           statements depending on whether the database named is the one on
566           the command line. The content of the statements is immaterial.
567
568           Suppose that mysql is invoked to process this set of statements:
569
570               DELETE FROM db2.t2;
571               USE db2;
572               DROP TABLE db1.t1;
573               CREATE TABLE db1.t1 (i INT);
574               USE db1;
575               INSERT INTO t1 (i) VALUES(1);
576               CREATE TABLE db2.t1 (j INT);
577
578           If the command line is mysql --force --one-database db1, mysql
579           handles the input as follows:
580
581           •   The DELETE statement is executed because the default database
582               is db1, even though the statement names a table in a different
583               database.
584
585           •   The DROP TABLE and CREATE TABLE statements are not executed
586               because the default database is not db1, even though the
587               statements name a table in db1.
588
589           •   The INSERT and CREATE TABLE statements are executed because the
590               default database is db1, even though the CREATE TABLE statement
591               names a table in a different database.
592
593--pager[=command] Use the given command for paging query output. If
594           the command is omitted, the default pager is the value of your
595           PAGER environment variable. Valid pagers are less, more, cat [>
596           filename], and so forth. This option works only on Unix and only in
597           interactive mode. To disable paging, use --skip-pager.  the section
598           called “MYSQL CLIENT COMMANDS”, discusses output paging further.
599
600--password[=password], -p[password] The password of the MySQL
601           account used for connecting to the server. The password value is
602           optional. If not given, mysql prompts for one. If given, there must
603           be no space between --password= or -p and the password following
604           it. If no password option is specified, the default is to send no
605           password.
606
607           Specifying a password on the command line should be considered
608           insecure. To avoid giving the password on the command line, use an
609           option file. See Section 6.1.2.1, “End-User Guidelines for Password
610           Security”.
611
612           To explicitly specify that there is no password and that mysql
613           should not prompt for one, use the --skip-password option.
614
615--password1[=pass_val] The password for multifactor authentication
616           factor 1 of the MySQL account used for connecting to the server.
617           The password value is optional. If not given, mysql prompts for
618           one. If given, there must be no space between --password1= and the
619           password following it. If no password option is specified, the
620           default is to send no password.
621
622           Specifying a password on the command line should be considered
623           insecure. To avoid giving the password on the command line, use an
624           option file. See Section 6.1.2.1, “End-User Guidelines for Password
625           Security”.
626
627           To explicitly specify that there is no password and that mysql
628           should not prompt for one, use the --skip-password1 option.
629
630           --password1 and --password are synonymous, as are --skip-password1
631           and --skip-password.
632
633--password2[=pass_val] The password for multifactor authentication
634           factor 2 of the MySQL account used for connecting to the server.
635           The semantics of this option are similar to the semantics for
636           --password1; see the description of that option for details.
637
638--password3[=pass_val] The password for multifactor authentication
639           factor 3 of the MySQL account used for connecting to the server.
640           The semantics of this option are similar to the semantics for
641           --password1; see the description of that option for details.
642
643--pipe, -W On Windows, connect to the server using a named pipe.
644           This option applies only if the server was started with the
645           named_pipe system variable enabled to support named-pipe
646           connections. In addition, the user making the connection must be a
647           member of the Windows group specified by the
648           named_pipe_full_access_group system variable.
649
650--plugin-authentication-kerberos-client-mode=value On Windows, the
651           authentication_kerberos_client authentication plugin supports this
652           plugin option. It provides two possible values that the client user
653           can set at runtime: SSPI and GSSAPI.
654
655           The default value for the client-side plugin option uses Security
656           Support Provider Interface (SSPI), which is capable of acquiring
657           credentials from the Windows in-memory cache. Alternatively, the
658           client user can select a mode that supports Generic Security
659           Service Application Program Interface (GSSAPI) through the MIT
660           Kerberos library on Windows. GSSAPI is capable of acquiring cached
661           credentials previously generated by using the kinit command.
662
663           For more information, see Commands for Windows Clients in GSSAPI
664           Mode.
665
666--plugin-dir=dir_name The directory in which to look for plugins.
667           Specify this option if the --default-auth option is used to specify
668           an authentication plugin but mysql does not find it. See
669           Section 6.2.17, “Pluggable Authentication”.
670
671--port=port_num, -P port_num For TCP/IP connections, the port
672           number to use.
673
674--print-defaults Print the program name and all options that it
675           gets from option files.
676
677           For additional information about this and other option-file
678           options, see Section 4.2.2.3, “Command-Line Options that Affect
679           Option-File Handling”.
680
681--prompt=format_str Set the prompt to the specified format. The
682           default is mysql>. The special sequences that the prompt can
683           contain are described in the section called “MYSQL CLIENT
684           COMMANDS”.
685
686--protocol={TCP|SOCKET|PIPE|MEMORY} The transport protocol to use
687           for connecting to the server. It is useful when the other
688           connection parameters normally result in use of a protocol other
689           than the one you want. For details on the permissible values, see
690           Section 4.2.7, “Connection Transport Protocols”.
691
692--quick, -q Do not cache each query result, print each row as it is
693           received. This may slow down the server if the output is suspended.
694           With this option, mysql does not use the history file.
695
696--raw, -r For tabular output, the “boxing” around columns enables
697           one column value to be distinguished from another. For nontabular
698           output (such as is produced in batch mode or when the --batch or
699           --silent option is given), special characters are escaped in the
700           output so they can be identified easily. Newline, tab, NUL, and
701           backslash are written as \n, \t, \0, and \\. The --raw option
702           disables this character escaping.
703
704           The following example demonstrates tabular versus nontabular output
705           and the use of raw mode to disable escaping:
706
707               % mysql
708               mysql> SELECT CHAR(92);
709               +----------+
710               | CHAR(92) |
711               +----------+
712               | \        |
713               +----------+
714               % mysql -s
715               mysql> SELECT CHAR(92);
716               CHAR(92)
717               \\
718               % mysql -s -r
719               mysql> SELECT CHAR(92);
720               CHAR(92)
721               \
722
723--reconnect If the connection to the server is lost, automatically
724           try to reconnect. A single reconnect attempt is made each time the
725           connection is lost. To suppress reconnection behavior, use
726           --skip-reconnect.
727
728--safe-updates, --i-am-a-dummy, -U If this option is enabled,
729           UPDATE and DELETE statements that do not use a key in the WHERE
730           clause or a LIMIT clause produce an error. In addition,
731           restrictions are placed on SELECT statements that produce (or are
732           estimated to produce) very large result sets. If you have set this
733           option in an option file, you can use --skip-safe-updates on the
734           command line to override it. For more information about this
735           option, see Using Safe-Updates Mode (--safe-updates).
736
737--select-limit=value The automatic limit for SELECT statements when
738           using --safe-updates. (Default value is 1,000.)
739
740--server-public-key-path=file_name The path name to a file in PEM
741           format containing a client-side copy of the public key required by
742           the server for RSA key pair-based password exchange. This option
743           applies to clients that authenticate with the sha256_password or
744           caching_sha2_password authentication plugin. This option is ignored
745           for accounts that do not authenticate with one of those plugins. It
746           is also ignored if RSA-based password exchange is not used, as is
747           the case when the client connects to the server using a secure
748           connection.
749
750           If --server-public-key-path=file_name is given and specifies a
751           valid public key file, it takes precedence over
752           --get-server-public-key.
753
754           For sha256_password, this option applies only if MySQL was built
755           using OpenSSL.
756
757           For information about the sha256_password and caching_sha2_password
758           plugins, see Section 6.4.1.3, “SHA-256 Pluggable Authentication”,
759           and Section 6.4.1.2, “Caching SHA-2 Pluggable Authentication”.
760
761--shared-memory-base-name=name On Windows, the shared-memory name
762           to use for connections made using shared memory to a local server.
763           The default value is MYSQL. The shared-memory name is
764           case-sensitive.
765
766           This option applies only if the server was started with the
767           shared_memory system variable enabled to support shared-memory
768           connections.
769
770--show-warnings Cause warnings to be shown after each statement if
771           there are any. This option applies to interactive and batch mode.
772
773--sigint-ignore Ignore SIGINT signals (typically the result of
774           typing Control+C).
775
776           Without this option, typing Control+C interrupts the current
777           statement if there is one, or cancels any partial input line
778           otherwise.
779
780--silent, -s Silent mode. Produce less output. This option can be
781           given multiple times to produce less and less output.
782
783           This option results in nontabular output format and escaping of
784           special characters. Escaping may be disabled by using raw mode; see
785           the description for the --raw option.
786
787--skip-column-names, -N Do not write column names in results.
788
789--skip-line-numbers, -L Do not write line numbers for errors.
790           Useful when you want to compare result files that include error
791           messages.
792
793--socket=path, -S path For connections to localhost, the Unix
794           socket file to use, or, on Windows, the name of the named pipe to
795           use.
796
797           On Windows, this option applies only if the server was started with
798           the named_pipe system variable enabled to support named-pipe
799           connections. In addition, the user making the connection must be a
800           member of the Windows group specified by the
801           named_pipe_full_access_group system variable.
802
803--ssl* Options that begin with --ssl specify whether to connect to
804           the server using encryption and indicate where to find SSL keys and
805           certificates. See the section called “Command Options for Encrypted
806           Connections”.
807
808--ssl-fips-mode={OFF|ON|STRICT} Controls whether to enable FIPS
809           mode on the client side. The --ssl-fips-mode option differs from
810           other --ssl-xxx options in that it is not used to establish
811           encrypted connections, but rather to affect which cryptographic
812           operations to permit. See Section 6.8, “FIPS Support”.
813
814           These --ssl-fips-mode values are permitted:
815
816           •   OFF: Disable FIPS mode.
817
818           •   ON: Enable FIPS mode.
819
820           •   STRICT: Enable “strict” FIPS mode.
821
822
823               Note
824               If the OpenSSL FIPS Object Module is not available, the only
825               permitted value for --ssl-fips-mode is OFF. In this case,
826               setting --ssl-fips-mode to ON or STRICT causes the client to
827               produce a warning at startup and to operate in non-FIPS mode.
828           As of MySQL 8.0.34, this option is deprecated. Expect it to be
829           removed in a future version of MySQL.
830
831--syslog, -j This option causes mysql to send interactive
832           statements to the system logging facility. On Unix, this is syslog;
833           on Windows, it is the Windows Event Log. The destination where
834           logged messages appear is system dependent. On Linux, the
835           destination is often the /var/log/messages file.
836
837           Here is a sample of output generated on Linux by using --syslog.
838           This output is formatted for readability; each logged message
839           actually takes a single line.
840
841               Mar  7 12:39:25 myhost MysqlClient[20824]:
842                 SYSTEM_USER:'oscar', MYSQL_USER:'my_oscar', CONNECTION_ID:23,
843                 DB_SERVER:'127.0.0.1', DB:'--', QUERY:'USE test;'
844               Mar  7 12:39:28 myhost MysqlClient[20824]:
845                 SYSTEM_USER:'oscar', MYSQL_USER:'my_oscar', CONNECTION_ID:23,
846                 DB_SERVER:'127.0.0.1', DB:'test', QUERY:'SHOW TABLES;'
847
848           For more information, see the section called “MYSQL CLIENT
849           LOGGING”.
850
851--table, -t Display output in table format. This is the default for
852           interactive use, but can be used to produce table output in batch
853           mode.
854
855--tee=file_name Append a copy of output to the given file. This
856           option works only in interactive mode.  the section called “MYSQL
857           CLIENT COMMANDS”, discusses tee files further.
858
859--tls-ciphersuites=ciphersuite_list The permissible ciphersuites
860           for encrypted connections that use TLSv1.3. The value is a list of
861           one or more colon-separated ciphersuite names. The ciphersuites
862           that can be named for this option depend on the SSL library used to
863           compile MySQL. For details, see Section 6.3.2, “Encrypted
864           Connection TLS Protocols and Ciphers”.
865
866           This option was added in MySQL 8.0.16.
867
868--tls-version=protocol_list The permissible TLS protocols for
869           encrypted connections. The value is a list of one or more
870           comma-separated protocol names. The protocols that can be named for
871           this option depend on the SSL library used to compile MySQL. For
872           details, see Section 6.3.2, “Encrypted Connection TLS Protocols and
873           Ciphers”.
874
875--unbuffered, -n Flush the buffer after each query.
876
877--user=user_name, -u user_name The user name of the MySQL account
878           to use for connecting to the server.
879
880--verbose, -v Verbose mode. Produce more output about what the
881           program does. This option can be given multiple times to produce
882           more and more output. (For example, -v -v -v produces table output
883           format even in batch mode.)
884
885--version, -V Display version information and exit.
886
887--vertical, -E Print query output rows vertically (one line per
888           column value). Without this option, you can specify vertical output
889           for individual statements by terminating them with \G.
890
891--wait, -w If the connection cannot be established, wait and retry
892           instead of aborting.
893
894--xml, -X Produce XML output.
895
896               <field name="column_name">NULL</field>
897
898           The output when --xml is used with mysql matches that of mysqldump
899           --xml. See mysqldump(1), for details.
900
901           The XML output also uses an XML namespace, as shown here:
902
903               $> mysql --xml -uroot -e "SHOW VARIABLES LIKE 'version%'"
904               <?xml version="1.0"?>
905               <resultset statement="SHOW VARIABLES LIKE 'version%'" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
906               <row>
907               <field name="Variable_name">version</field>
908               <field name="Value">5.0.40-debug</field>
909               </row>
910               <row>
911               <field name="Variable_name">version_comment</field>
912               <field name="Value">Source distribution</field>
913               </row>
914               <row>
915               <field name="Variable_name">version_compile_machine</field>
916               <field name="Value">i686</field>
917               </row>
918               <row>
919               <field name="Variable_name">version_compile_os</field>
920               <field name="Value">suse-linux-gnu</field>
921               </row>
922               </resultset>
923
924--zstd-compression-level=level The compression level to use for
925           connections to the server that use the zstd compression algorithm.
926           The permitted levels are from 1 to 22, with larger values
927           indicating increasing levels of compression. The default zstd
928           compression level is 3. The compression level setting has no effect
929           on connections that do not use zstd compression.
930
931           For more information, see Section 4.2.8, “Connection Compression
932           Control”.
933
934           This option was added in MySQL 8.0.18.
935

MYSQL CLIENT COMMANDS

937       mysql sends each SQL statement that you issue to the server to be
938       executed. There is also a set of commands that mysql itself interprets.
939       For a list of these commands, type help or \h at the mysql> prompt:
940
941           mysql> help
942           List of all MySQL commands:
943           Note that all text commands must be first on line and end with ';'
944           ?         (\?) Synonym for `help'.
945           clear     (\c) Clear the current input statement.
946           connect   (\r) Reconnect to the server. Optional arguments are db and host.
947           delimiter (\d) Set statement delimiter.
948           edit      (\e) Edit command with $EDITOR.
949           ego       (\G) Send command to mysql server, display result vertically.
950           exit      (\q) Exit mysql. Same as quit.
951           go        (\g) Send command to mysql server.
952           help      (\h) Display this help.
953           nopager   (\n) Disable pager, print to stdout.
954           notee     (\t) Don't write into outfile.
955           pager     (\P) Set PAGER [to_pager]. Print the query results via PAGER.
956           print     (\p) Print current command.
957           prompt    (\R) Change your mysql prompt.
958           quit      (\q) Quit mysql.
959           rehash    (\#) Rebuild completion hash.
960           source    (\.) Execute an SQL script file. Takes a file name as an argument.
961           status    (\s) Get status information from the server.
962           system    (\!) Execute a system shell command.
963           tee       (\T) Set outfile [to_outfile]. Append everything into given
964                          outfile.
965           use       (\u) Use another database. Takes database name as argument.
966           charset   (\C) Switch to another charset. Might be needed for processing
967                          binlog with multi-byte charsets.
968           warnings  (\W) Show warnings after every statement.
969           nowarning (\w) Don't show warnings after every statement.
970           resetconnection(\x) Clean session context.
971           query_attributes Sets string parameters (name1 value1 name2 value2 ...)
972           for the next query to pick up.
973           ssl_session_data_print Serializes the current SSL session data to stdout
974           or file.
975           For server side help, type 'help contents'
976
977       If mysql is invoked with the --binary-mode option, all mysql commands
978       are disabled except charset and delimiter in noninteractive mode (for
979       input piped to mysql or loaded using the source command).
980
981       Each command has both a long and short form. The long form is not
982       case-sensitive; the short form is. The long form can be followed by an
983       optional semicolon terminator, but the short form should not.
984
985       The use of short-form commands within multiple-line /* ... */ comments
986       is not supported. Short-form commands do work within single-line /*!
987       ... */ version comments, as do /*+ ... */ optimizer-hint comments,
988       which are stored in object definitions. If there is a concern that
989       optimizer-hint comments may be stored in object definitions so that
990       dump files when reloaded with mysql would result in execution of such
991       commands, either invoke mysql with the --binary-mode option or use a
992       reload client other than mysql.
993
994       •   help [arg], \h [arg], \? [arg], ? [arg]
995
996           Display a help message listing the available mysql commands.
997
998           If you provide an argument to the help command, mysql uses it as a
999           search string to access server-side help from the contents of the
1000           MySQL Reference Manual. For more information, see the section
1001           called “MYSQL CLIENT SERVER-SIDE HELP”.
1002
1003       •   charset charset_name, \C charset_name
1004
1005           Change the default character set and issue a SET NAMES statement.
1006           This enables the character set to remain synchronized on the client
1007           and server if mysql is run with auto-reconnect enabled (which is
1008           not recommended), because the specified character set is used for
1009           reconnects.
1010
1011       •   clear, \c
1012
1013           Clear the current input. Use this if you change your mind about
1014           executing the statement that you are entering.
1015
1016       •   connect [db_name [host_name]], \r [db_name [host_name]]
1017
1018           Reconnect to the server. The optional database name and host name
1019           arguments may be given to specify the default database or the host
1020           where the server is running. If omitted, the current values are
1021           used.
1022
1023           If the connect command specifies a host name argument, that host
1024           takes precedence over any --dns-srv-name option given at mysql
1025           startup to specify a DNS SRV record.
1026
1027       •   delimiter str, \d str
1028
1029           Change the string that mysql interprets as the separator between
1030           SQL statements. The default is the semicolon character (;).
1031
1032           The delimiter string can be specified as an unquoted or quoted
1033           argument on the delimiter command line. Quoting can be done with
1034           either single quote ('), double quote ("), or backtick (`)
1035           characters. To include a quote within a quoted string, either quote
1036           the string with a different quote character or escape the quote
1037           with a backslash (\) character. Backslash should be avoided outside
1038           of quoted strings because it is the escape character for MySQL. For
1039           an unquoted argument, the delimiter is read up to the first space
1040           or end of line. For a quoted argument, the delimiter is read up to
1041           the matching quote on the line.
1042
1043           mysql interprets instances of the delimiter string as a statement
1044           delimiter anywhere it occurs, except within quoted strings. Be
1045           careful about defining a delimiter that might occur within other
1046           words. For example, if you define the delimiter as X, it is not
1047           possible to use the word INDEX in statements.  mysql interprets
1048           this as INDE followed by the delimiter X.
1049
1050           When the delimiter recognized by mysql is set to something other
1051           than the default of ;, instances of that character are sent to the
1052           server without interpretation. However, the server itself still
1053           interprets ; as a statement delimiter and processes statements
1054           accordingly. This behavior on the server side comes into play for
1055           multiple-statement execution (see Multiple Statement Execution
1056           Support[3]), and for parsing the body of stored procedures and
1057           functions, triggers, and events (see Section 25.1, “Defining Stored
1058           Programs”).
1059
1060       •   edit, \e
1061
1062           Edit the current input statement.  mysql checks the values of the
1063           EDITOR and VISUAL environment variables to determine which editor
1064           to use. The default editor is vi if neither variable is set.
1065
1066           The edit command works only in Unix.
1067
1068       •   ego, \G
1069
1070           Send the current statement to the server to be executed and display
1071           the result using vertical format.
1072
1073       •   exit, \q
1074
1075           Exit mysql.
1076
1077       •   go, \g
1078
1079           Send the current statement to the server to be executed.
1080
1081       •   nopager, \n
1082
1083           Disable output paging. See the description for pager.
1084
1085           The nopager command works only in Unix.
1086
1087       •   notee, \t
1088
1089           Disable output copying to the tee file. See the description for
1090           tee.
1091
1092       •   nowarning, \w
1093
1094           Disable display of warnings after each statement.
1095
1096       •   pager [command], \P [command]
1097
1098           Enable output paging. By using the --pager option when you invoke
1099           mysql, it is possible to browse or search query results in
1100           interactive mode with Unix programs such as less, more, or any
1101           other similar program. If you specify no value for the option,
1102           mysql checks the value of the PAGER environment variable and sets
1103           the pager to that. Pager functionality works only in interactive
1104           mode.
1105
1106           Output paging can be enabled interactively with the pager command
1107           and disabled with nopager. The command takes an optional argument;
1108           if given, the paging program is set to that. With no argument, the
1109           pager is set to the pager that was set on the command line, or
1110           stdout if no pager was specified.
1111
1112           Output paging works only in Unix because it uses the popen()
1113           function, which does not exist on Windows. For Windows, the tee
1114           option can be used instead to save query output, although it is not
1115           as convenient as pager for browsing output in some situations.
1116
1117       •   print, \p
1118
1119           Print the current input statement without executing it.
1120
1121       •   prompt [str], \R [str]
1122
1123           Reconfigure the mysql prompt to the given string. The special
1124           character sequences that can be used in the prompt are described
1125           later in this section.
1126
1127           If you specify the prompt command with no argument, mysql resets
1128           the prompt to the default of mysql>.
1129
1130       •   query_attributes name value [name value ...]
1131
1132           Define query attributes that apply to the next query sent to the
1133           server. For discussion of the purpose and use of query attributes,
1134           see Section 9.6, “Query Attributes”.
1135
1136           The query_attributes command follows these rules:
1137
1138           •   The format and quoting rules for attribute names and values are
1139               the same as for the delimiter command.
1140
1141           •   The command permits up to 32 attribute name/value pairs. Names
1142               and values may be up to 1024 characters long. If a name is
1143               given without a value, an error occurs.
1144
1145           •   If multiple query_attributes commands are issued prior to query
1146               execution, only the last command applies. After sending the
1147               query, mysql clears the attribute set.
1148
1149           •   If multiple attributes are defined with the same name, attempts
1150               to retrieve the attribute value have an undefined result.
1151
1152           •   An attribute defined with an empty name cannot be retrieved by
1153               name.
1154
1155           •   If a reconnect occurs while mysql executes the query, mysql
1156               restores the attributes after reconnecting so the query can be
1157               executed again with the same attributes.
1158
1159
1160       •   quit, \q
1161
1162           Exit mysql.
1163
1164       •   rehash, \#
1165
1166           Rebuild the completion hash that enables database, table, and
1167           column name completion while you are entering statements. (See the
1168           description for the --auto-rehash option.)
1169
1170       •   resetconnection, \x
1171
1172           Reset the connection to clear the session state. This includes
1173           clearing any current query attributes defined using the
1174           query_attributes command.
1175
1176           Resetting a connection has effects similar to mysql_change_user()
1177           or an auto-reconnect except that the connection is not closed and
1178           reopened, and re-authentication is not done. See
1179           mysql_change_user()[4], and Automatic Reconnection Control[5].
1180
1181           This example shows how resetconnection clears a value maintained in
1182           the session state:
1183
1184               mysql> SELECT LAST_INSERT_ID(3);
1185               +-------------------+
1186               | LAST_INSERT_ID(3) |
1187               +-------------------+
1188               |                 3 |
1189               +-------------------+
1190               mysql> SELECT LAST_INSERT_ID();
1191               +------------------+
1192               | LAST_INSERT_ID() |
1193               +------------------+
1194               |                3 |
1195               +------------------+
1196               mysql> resetconnection;
1197               mysql> SELECT LAST_INSERT_ID();
1198               +------------------+
1199               | LAST_INSERT_ID() |
1200               +------------------+
1201               |                0 |
1202               +------------------+
1203
1204       •   source file_name, \. file_name
1205
1206           Read the named file and executes the statements contained therein.
1207           On Windows, specify path name separators as / or \\.
1208
1209           Quote characters are taken as part of the file name itself. For
1210           best results, the name should not include space characters.
1211
1212       •   ssl_session_data_print [file_name]
1213
1214           Fetches, serializes, and optionally stores the session data of a
1215           successful connection. The optional file name and arguments may be
1216           given to specify the file to store serialized session data. If
1217           omitted, the session data is printed to stdout.
1218
1219           If the MySQL session is configured for reuse, session data from the
1220           file is deserialized and supplied to the connect command to
1221           reconnect. When the session is reused successfully, the status
1222           command contains a row showing SSL session reused: true while the
1223           client remains reconnected to the server.
1224
1225       •   status, \s
1226
1227           Provide status information about the connection and the server you
1228           are using. If you are running with --safe-updates enabled, status
1229           also prints the values for the mysql variables that affect your
1230           queries.
1231
1232       •   system command, \! command
1233
1234           Execute the given command using your default command interpreter.
1235
1236           Prior to MySQL 8.0.19, the system command works only in Unix. As of
1237           8.0.19, it also works on Windows.
1238
1239       •   tee [file_name], \T [file_name]
1240
1241           By using the --tee option when you invoke mysql, you can log
1242           statements and their output. All the data displayed on the screen
1243           is appended into a given file. This can be very useful for
1244           debugging purposes also.  mysql flushes results to the file after
1245           each statement, just before it prints its next prompt. Tee
1246           functionality works only in interactive mode.
1247
1248           You can enable this feature interactively with the tee command.
1249           Without a parameter, the previous file is used. The tee file can be
1250           disabled with the notee command. Executing tee again re-enables
1251           logging.
1252
1253       •   use db_name, \u db_name
1254
1255           Use db_name as the default database.
1256
1257       •   warnings, \W
1258
1259           Enable display of warnings after each statement (if there are any).
1260
1261       Here are a few tips about the pager command:
1262
1263       •   You can use it to write to a file and the results go only to the
1264           file:
1265
1266               mysql> pager cat > /tmp/log.txt
1267
1268           You can also pass any options for the program that you want to use
1269           as your pager:
1270
1271               mysql> pager less -n -i -S
1272
1273       •   In the preceding example, note the -S option. You may find it very
1274           useful for browsing wide query results. Sometimes a very wide
1275           result set is difficult to read on the screen. The -S option to
1276           less can make the result set much more readable because you can
1277           scroll it horizontally using the left-arrow and right-arrow keys.
1278           You can also use -S interactively within less to switch the
1279           horizontal-browse mode on and off. For more information, read the
1280           less manual page:
1281
1282               man less
1283
1284       •   The -F and -X options may be used with less to cause it to exit if
1285           output fits on one screen, which is convenient when no scrolling is
1286           necessary:
1287
1288               mysql> pager less -n -i -S -F -X
1289
1290       •   You can specify very complex pager commands for handling query
1291           output:
1292
1293               mysql> pager cat | tee /dr1/tmp/res.txt \
1294                         | tee /dr2/tmp/res2.txt | less -n -i -S
1295
1296           In this example, the command would send query results to two files
1297           in two different directories on two different file systems mounted
1298           on /dr1 and /dr2, yet still display the results onscreen using
1299           less.
1300
1301       You can also combine the tee and pager functions. Have a tee file
1302       enabled and pager set to less, and you are able to browse the results
1303       using the less program and still have everything appended into a file
1304       the same time. The difference between the Unix tee used with the pager
1305       command and the mysql built-in tee command is that the built-in tee
1306       works even if you do not have the Unix tee available. The built-in tee
1307       also logs everything that is printed on the screen, whereas the Unix
1308       tee used with pager does not log quite that much. Additionally, tee
1309       file logging can be turned on and off interactively from within mysql.
1310       This is useful when you want to log some queries to a file, but not
1311       others.
1312
1313       The prompt command reconfigures the default mysql> prompt. The string
1314       for defining the prompt can contain the following special sequences.
1315
1316.br
1317.br
1318.br
131972
1320       ┌───────────────────────────┬────────────────────────────┐
1321Option                     Description                
1322       ├───────────────────────────┼────────────────────────────┤
1323       │                           │ The current connection     │
1324       │                           │ identifier                 │
1325       ├───────────────────────────┼────────────────────────────┤
1326       │                           │ A counter that increments  │
1327       │                           │ for each statement you     │
1328       │                           │ issue                      │
1329       ├───────────────────────────┼────────────────────────────┤
1330       │                           │ The full current date      │
1331       ├───────────────────────────┼────────────────────────────┤
1332       │                           │ The default database       │
1333       ├───────────────────────────┼────────────────────────────┤
1334       │                           │ The server host            │
1335       ├───────────────────────────┼────────────────────────────┤
1336       │                           │ The current delimiter      │
1337       ├───────────────────────────┼────────────────────────────┤
1338       │                           │ Minutes of the current     │
1339       │                           │ time                       │
1340       ├───────────────────────────┼────────────────────────────┤
1341       │                           │ A newline character        │
1342       ├───────────────────────────┼────────────────────────────┤
1343       │                           │ The current month in       │
1344       │                           │ three-letter format (Jan,  │
1345       │                           │ Feb, ...)                  │
1346       ├───────────────────────────┼────────────────────────────┤
1347       │                           │ The current month in       │
1348       │                           │ numeric format             │
1349       ├───────────────────────────┼────────────────────────────┤
1350       │P                          │ am/pm                      │
1351       ├───────────────────────────┼────────────────────────────┤
1352       │                           │ The current TCP/IP port or │
1353       │                           │ socket file                │
1354       ├───────────────────────────┼────────────────────────────┤
1355       │                           │ The current time, in       │
1356       │                           │ 24-hour military time      │
1357       │                           │ (0–23)                     │
1358       ├───────────────────────────┼────────────────────────────┤
1359       │                           │ The current time, standard │
1360       │                           │ 12-hour time (1–12)        │
1361       ├───────────────────────────┼────────────────────────────┤
1362       │                           │ Semicolon                  │
1363       ├───────────────────────────┼────────────────────────────┤
1364       │                           │ Seconds of the current     │
1365       │                           │ time                       │
1366       ├───────────────────────────┼────────────────────────────┤
1367       │T                          │ Print an asterisk (*) if   │
1368       │                           │ the current session is     │
1369       │                           │               inside a     │
1370       │                           │ transaction block (from    │
1371       │                           │ MySQL 8.0.28)              │
1372       ├───────────────────────────┼────────────────────────────┤
1373       │                           │ A tab character            │
1374       ├───────────────────────────┼────────────────────────────┤
1375       │U                          │                            │
1376       │                           │        Your full           │
1377       │                           │        user_name@host_name
1378       │                           │        account name        │
1379       ├───────────────────────────┼────────────────────────────┤
1380       │                           │ Your user name             │
1381       ├───────────────────────────┼────────────────────────────┤
1382       │                           │ The server version         │
1383       ├───────────────────────────┼────────────────────────────┤
1384       │                           │ The current day of the     │
1385       │                           │ week in three-letter       │
1386       │                           │ format (Mon, Tue, ...)     │
1387       ├───────────────────────────┼────────────────────────────┤
1388       │                           │ The current year, four     │
1389       │                           │ digits                     │
1390       ├───────────────────────────┼────────────────────────────┤
1391       │y                          │ The current year, two      │
1392       │                           │ digits                     │
1393       ├───────────────────────────┼────────────────────────────┤
1394       │_                          │ A space                    │
1395       ├───────────────────────────┼────────────────────────────┤
1396       │\                          │ A space (a space follows   │
1397       │                           │ the backslash)             │
1398       ├───────────────────────────┼────────────────────────────┤
1399       │´                          │ Single quote               │
1400       ├───────────────────────────┼────────────────────────────┤
1401       │                           │ Double quote               │
1402       ├───────────────────────────┼────────────────────────────┤
1403       │T}:T{ A literal  backslash │                            │
1404       │character                  │                            │
1405       ├───────────────────────────┼────────────────────────────┤
1406       │\fIx                       │                            │
1407       │                           │        x, for any “x” not  │
1408       │                           │        listed above        │
1409       └───────────────────────────┴────────────────────────────┘
1410
1411       You can set the prompt in several ways:
1412
1413Use an environment variable.  You can set the MYSQL_PS1 environment
1414           variable to a prompt string. For example:
1415
1416               export MYSQL_PS1="(\u@\h) [\d]> "
1417
1418Use a command-line option.  You can set the --prompt option on the
1419           command line to mysql. For example:
1420
1421               $> mysql --prompt="(\u@\h) [\d]> "
1422               (user@host) [database]>
1423
1424Use an option file.  You can set the prompt option in the [mysql]
1425           group of any MySQL option file, such as /etc/my.cnf or the .my.cnf
1426           file in your home directory. For example:
1427
1428               [mysql]
1429               prompt=(\\u@\\h) [\\d]>\\_
1430
1431           In this example, note that the backslashes are doubled. If you set
1432           the prompt using the prompt option in an option file, it is
1433           advisable to double the backslashes when using the special prompt
1434           options. There is some overlap in the set of permissible prompt
1435           options and the set of special escape sequences that are recognized
1436           in option files. (The rules for escape sequences in option files
1437           are listed in Section 4.2.2.2, “Using Option Files”.) The overlap
1438           may cause you problems if you use single backslashes. For example,
1439           \s is interpreted as a space rather than as the current seconds
1440           value. The following example shows how to define a prompt within an
1441           option file to include the current time in hh:mm:ss> format:
1442
1443               [mysql]
1444               prompt="\\r:\\m:\\s> "
1445
1446Set the prompt interactively.  You can change your prompt
1447           interactively by using the prompt (or \R) command. For example:
1448
1449               mysql> prompt (\u@\h) [\d]>\_
1450               PROMPT set to '(\u@\h) [\d]>\_'
1451               (user@host) [database]>
1452               (user@host) [database]> prompt
1453               Returning to default PROMPT of mysql>
1454               mysql>
1455

MYSQL CLIENT LOGGING

1457       The mysql client can do these types of logging for statements executed
1458       interactively:
1459
1460       •   On Unix, mysql writes the statements to a history file. By default,
1461           this file is named .mysql_history in your home directory. To
1462           specify a different file, set the value of the MYSQL_HISTFILE
1463           environment variable.
1464
1465       •   On all platforms, if the --syslog option is given, mysql writes the
1466           statements to the system logging facility. On Unix, this is syslog;
1467           on Windows, it is the Windows Event Log. The destination where
1468           logged messages appear is system dependent. On Linux, the
1469           destination is often the /var/log/messages file.
1470
1471       The following discussion describes characteristics that apply to all
1472       logging types and provides information specific to each logging type.
1473
1474       •   How Logging Occurs
1475
1476       •   Controlling the History File
1477
1478       •   syslog Logging Characteristics
1479       How Logging Occurs
1480
1481       For each enabled logging destination, statement logging occurs as
1482       follows:
1483
1484       •   Statements are logged only when executed interactively. Statements
1485           are noninteractive, for example, when read from a file or a pipe.
1486           It is also possible to suppress statement logging by using the
1487           --batch or --execute option.
1488
1489       •   Statements are ignored and not logged if they match any pattern in
1490           the “ignore” list. This list is described later.
1491
1492mysql logs each nonignored, nonempty statement line individually.
1493
1494       •   If a nonignored statement spans multiple lines (not including the
1495           terminating delimiter), mysql concatenates the lines to form the
1496           complete statement, maps newlines to spaces, and logs the result,
1497           plus a delimiter.
1498
1499       Consequently, an input statement that spans multiple lines can be
1500       logged twice. Consider this input:
1501
1502           mysql> SELECT
1503               -> 'Today is'
1504               -> ,
1505               -> CURDATE()
1506               -> ;
1507
1508       In this case, mysql logs the “SELECT”, “'Today is'”, “,”, “CURDATE()”,
1509       and “;” lines as it reads them. It also logs the complete statement,
1510       after mapping SELECT\n'Today is'\n,\nCURDATE() to SELECT 'Today is' ,
1511       CURDATE(), plus a delimiter. Thus, these lines appear in logged output:
1512
1513           SELECT
1514           'Today is'
1515           ,
1516           CURDATE()
1517           ;
1518           SELECT 'Today is' , CURDATE();
1519
1520       mysql ignores for logging purposes statements that match any pattern in
1521       the “ignore” list. By default, the pattern list is
1522       "*IDENTIFIED*:*PASSWORD*", to ignore statements that refer to
1523       passwords. Pattern matching is not case-sensitive. Within patterns, two
1524       characters are special:
1525
1526       •   ?  matches any single character.
1527
1528       •   * matches any sequence of zero or more characters.
1529
1530       To specify additional patterns, use the --histignore option or set the
1531       MYSQL_HISTIGNORE environment variable. (If both are specified, the
1532       option value takes precedence.) The value should be a list of one or
1533       more colon-separated patterns, which are appended to the default
1534       pattern list.
1535
1536       Patterns specified on the command line might need to be quoted or
1537       escaped to prevent your command interpreter from treating them
1538       specially. For example, to suppress logging for UPDATE and DELETE
1539       statements in addition to statements that refer to passwords, invoke
1540       mysql like this:
1541
1542           mysql --histignore="*UPDATE*:*DELETE*"
1543
1544       Controlling the History File
1545
1546       The .mysql_history file should be protected with a restrictive access
1547       mode because sensitive information might be written to it, such as the
1548       text of SQL statements that contain passwords. See Section 6.1.2.1,
1549       “End-User Guidelines for Password Security”. Statements in the file are
1550       accessible from the mysql client when the up-arrow key is used to
1551       recall the history. See Disabling Interactive History.
1552
1553       If you do not want to maintain a history file, first remove
1554       .mysql_history if it exists. Then use either of the following
1555       techniques to prevent it from being created again:
1556
1557       •   Set the MYSQL_HISTFILE environment variable to /dev/null. To cause
1558           this setting to take effect each time you log in, put it in one of
1559           your shell's startup files.
1560
1561       •   Create .mysql_history as a symbolic link to /dev/null; this need be
1562           done only once:
1563
1564               ln -s /dev/null $HOME/.mysql_history
1565       syslog Logging Characteristics
1566
1567       If the --syslog option is given, mysql writes interactive statements to
1568       the system logging facility. Message logging has the following
1569       characteristics.
1570
1571       Logging occurs at the “information” level. This corresponds to the
1572       LOG_INFO priority for syslog on Unix/Linux syslog capability and to
1573       EVENTLOG_INFORMATION_TYPE for the Windows Event Log. Consult your
1574       system documentation for configuration of your logging capability.
1575
1576       Message size is limited to 1024 bytes.
1577
1578       Messages consist of the identifier MysqlClient followed by these
1579       values:
1580
1581       •   SYSTEM_USER
1582
1583           The operating system user name (login name) or -- if the user is
1584           unknown.
1585
1586       •   MYSQL_USER
1587
1588           The MySQL user name (specified with the --user option) or -- if the
1589           user is unknown.
1590
1591       •   CONNECTION_ID:
1592
1593           The client connection identifier. This is the same as the
1594           CONNECTION_ID() function value within the session.
1595
1596       •   DB_SERVER
1597
1598           The server host or -- if the host is unknown.
1599
1600       •   DB
1601
1602           The default database or -- if no database has been selected.
1603
1604       •   QUERY
1605
1606           The text of the logged statement.
1607
1608       Here is a sample of output generated on Linux by using --syslog. This
1609       output is formatted for readability; each logged message actually takes
1610       a single line.
1611
1612           Mar  7 12:39:25 myhost MysqlClient[20824]:
1613             SYSTEM_USER:'oscar', MYSQL_USER:'my_oscar', CONNECTION_ID:23,
1614             DB_SERVER:'127.0.0.1', DB:'--', QUERY:'USE test;'
1615           Mar  7 12:39:28 myhost MysqlClient[20824]:
1616             SYSTEM_USER:'oscar', MYSQL_USER:'my_oscar', CONNECTION_ID:23,
1617             DB_SERVER:'127.0.0.1', DB:'test', QUERY:'SHOW TABLES;'
1618

MYSQL CLIENT SERVER-SIDE HELP

1620           mysql> help search_string
1621
1622       If you provide an argument to the help command, mysql uses it as a
1623       search string to access server-side help from the contents of the MySQL
1624       Reference Manual. The proper operation of this command requires that
1625       the help tables in the mysql database be initialized with help topic
1626       information (see Section 5.1.17, “Server-Side Help Support”).
1627
1628       If there is no match for the search string, the search fails:
1629
1630           mysql> help me
1631           Nothing found
1632           Please try to run 'help contents' for a list of all accessible topics
1633
1634       Use help contents to see a list of the help categories:
1635
1636           mysql> help contents
1637           You asked for help about help category: "Contents"
1638           For more information, type 'help <item>', where <item> is one of the
1639           following categories:
1640              Account Management
1641              Administration
1642              Data Definition
1643              Data Manipulation
1644              Data Types
1645              Functions
1646              Functions and Modifiers for Use with GROUP BY
1647              Geographic Features
1648              Language Structure
1649              Plugins
1650              Storage Engines
1651              Stored Routines
1652              Table Maintenance
1653              Transactions
1654              Triggers
1655
1656       If the search string matches multiple items, mysql shows a list of
1657       matching topics:
1658
1659           mysql> help logs
1660           Many help items for your request exist.
1661           To make a more specific request, please type 'help <item>',
1662           where <item> is one of the following topics:
1663              SHOW
1664              SHOW BINARY LOGS
1665              SHOW ENGINE
1666              SHOW LOGS
1667
1668       Use a topic as the search string to see the help entry for that topic:
1669
1670           mysql> help show binary logs
1671           Name: 'SHOW BINARY LOGS'
1672           Description:
1673           Syntax:
1674           SHOW BINARY LOGS
1675           SHOW MASTER LOGS
1676           Lists the binary log files on the server. This statement is used as
1677           part of the procedure described in [purge-binary-logs], that shows how
1678           to determine which logs can be purged.
1679
1680           mysql> SHOW BINARY LOGS;
1681           +---------------+-----------+-----------+
1682           | Log_name      | File_size | Encrypted |
1683           +---------------+-----------+-----------+
1684           | binlog.000015 |    724935 | Yes       |
1685           | binlog.000016 |    733481 | Yes       |
1686           +---------------+-----------+-----------+
1687
1688       The search string can contain the wildcard characters % and _. These
1689       have the same meaning as for pattern-matching operations performed with
1690       the LIKE operator. For example, HELP rep% returns a list of topics that
1691       begin with rep:
1692
1693           mysql> HELP rep%
1694           Many help items for your request exist.
1695           To make a more specific request, please type 'help <item>',
1696           where <item> is one of the following
1697           topics:
1698              REPAIR TABLE
1699              REPEAT FUNCTION
1700              REPEAT LOOP
1701              REPLACE
1702              REPLACE FUNCTION
1703

EXECUTING SQL STATEMENTS FROM A TEXT FILE

1705       The mysql client typically is used interactively, like this:
1706
1707           mysql db_name
1708
1709       However, it is also possible to put your SQL statements in a file and
1710       then tell mysql to read its input from that file. To do so, create a
1711       text file text_file that contains the statements you wish to execute.
1712       Then invoke mysql as shown here:
1713
1714           mysql db_name < text_file
1715
1716       If you place a USE db_name statement as the first statement in the
1717       file, it is unnecessary to specify the database name on the command
1718       line:
1719
1720           mysql < text_file
1721
1722       If you are already running mysql, you can execute an SQL script file
1723       using the source command or \.  command:
1724
1725           mysql> source file_name
1726           mysql> \. file_name
1727
1728       Sometimes you may want your script to display progress information to
1729       the user. For this you can insert statements like this:
1730
1731           SELECT '<info_to_display>' AS ' ';
1732
1733       The statement shown outputs <info_to_display>.
1734
1735       You can also invoke mysql with the --verbose option, which causes each
1736       statement to be displayed before the result that it produces.
1737
1738       mysql ignores Unicode byte order mark (BOM) characters at the beginning
1739       of input files. Previously, it read them and sent them to the server,
1740       resulting in a syntax error. Presence of a BOM does not cause mysql to
1741       change its default character set. To do that, invoke mysql with an
1742       option such as --default-character-set=utf8mb4.
1743
1744       For more information about batch mode, see Section 3.5, “Using mysql in
1745       Batch Mode”.
1746

MYSQL CLIENT TIPS

1748       This section provides information about techniques for more effective
1749       use of mysql and about mysql operational behavior.
1750
1751       •   Input-Line Editing
1752
1753       •   Disabling Interactive History
1754
1755       •   Unicode Support on Windows
1756
1757       •   Displaying Query Results Vertically
1758
1759       •   Using Safe-Updates Mode (--safe-updates)
1760
1761       •   Disabling mysql Auto-Reconnect
1762
1763       •   mysql Client Parser Versus Server Parser
1764       Input-Line Editing
1765
1766       mysql supports input-line editing, which enables you to modify the
1767       current input line in place or recall previous input lines. For
1768       example, the left-arrow and right-arrow keys move horizontally within
1769       the current input line, and the up-arrow and down-arrow keys move up
1770       and down through the set of previously entered lines.  Backspace
1771       deletes the character before the cursor and typing new characters
1772       enters them at the cursor position. To enter the line, press Enter.
1773
1774       On Windows, the editing key sequences are the same as supported for
1775       command editing in console windows. On Unix, the key sequences depend
1776       on the input library used to build mysql (for example, the libedit or
1777       readline library).
1778
1779       Documentation for the libedit and readline libraries is available
1780       online. To change the set of key sequences permitted by a given input
1781       library, define key bindings in the library startup file. This is a
1782       file in your home directory: .editrc for libedit and .inputrc for
1783       readline.
1784
1785       For example, in libedit, Control+W deletes everything before the
1786       current cursor position and Control+U deletes the entire line. In
1787       readline, Control+W deletes the word before the cursor and Control+U
1788       deletes everything before the current cursor position. If mysql was
1789       built using libedit, a user who prefers the readline behavior for these
1790       two keys can put the following lines in the .editrc file (creating the
1791       file if necessary):
1792
1793           bind "^W" ed-delete-prev-word
1794           bind "^U" vi-kill-line-prev
1795
1796       To see the current set of key bindings, temporarily put a line that
1797       says only bind at the end of .editrc.  mysql shows the bindings when it
1798       starts.  Disabling Interactive History
1799
1800       The up-arrow key enables you to recall input lines from current and
1801       previous sessions. In cases where a console is shared, this behavior
1802       may be unsuitable.  mysql supports disabling the interactive history
1803       partially or fully, depending on the host platform.
1804
1805       On Windows, the history is stored in memory.  Alt+F7 deletes all input
1806       lines stored in memory for the current history buffer. It also deletes
1807       the list of sequential numbers in front of the input lines displayed
1808       with F7 and recalled (by number) with F9. New input lines entered after
1809       you press Alt+F7 repopulate the current history buffer. Clearing the
1810       buffer does not prevent logging to the Windows Event Viewer, if the
1811       --syslog option was used to start mysql. Closing the console window
1812       also clears the current history buffer.
1813
1814       To disable interactive history on Unix, first delete the .mysql_history
1815       file, if it exists (previous entries are recalled otherwise). Then
1816       start mysql with the --histignore="*" option to ignore all new input
1817       lines. To re-enable the recall (and logging) behavior, restart mysql
1818       without the option.
1819
1820       If you prevent the .mysql_history file from being created (see
1821       Controlling the History File) and use --histignore="*" to start the
1822       mysql client, the interactive history recall facility is disabled
1823       fully. Alternatively, if you omit the --histignore option, you can
1824       recall the input lines entered during the current session.  Unicode
1825       Support on Windows
1826
1827       Windows provides APIs based on UTF-16LE for reading from and writing to
1828       the console; the mysql client for Windows is able to use these APIs.
1829       The Windows installer creates an item in the MySQL menu named MySQL
1830       command line client - Unicode. This item invokes the mysql client with
1831       properties set to communicate through the console to the MySQL server
1832       using Unicode.
1833
1834       To take advantage of this support manually, run mysql within a console
1835       that uses a compatible Unicode font and set the default character set
1836       to a Unicode character set that is supported for communication with the
1837       server:
1838
1839        1. Open a console window.
1840
1841        2. Go to the console window properties, select the font tab, and
1842           choose Lucida Console or some other compatible Unicode font. This
1843           is necessary because console windows start by default using a DOS
1844           raster font that is inadequate for Unicode.
1845
1846        3. Execute mysql.exe with the --default-character-set=utf8mb4 (or
1847           utf8mb3) option. This option is necessary because utf16le is one of
1848           the character sets that cannot be used as the client character set.
1849           See the section called “Impermissible Client Character Sets”.
1850
1851       With those changes, mysql uses the Windows APIs to communicate with the
1852       console using UTF-16LE, and communicate with the server using UTF-8.
1853       (The menu item mentioned previously sets the font and character set as
1854       just described.)
1855
1856       To avoid those steps each time you run mysql, you can create a shortcut
1857       that invokes mysql.exe. The shortcut should set the console font to
1858       Lucida Console or some other compatible Unicode font, and pass the
1859       --default-character-set=utf8mb4 (or utf8mb3) option to mysql.exe.
1860
1861       Alternatively, create a shortcut that only sets the console font, and
1862       set the character set in the [mysql] group of your my.ini file:
1863
1864           [mysql]
1865           default-character-set=utf8mb4   # or utf8mb3
1866
1867       Displaying Query Results Vertically
1868
1869       Some query results are much more readable when displayed vertically,
1870       instead of in the usual horizontal table format. Queries can be
1871       displayed vertically by terminating the query with \G instead of a
1872       semicolon. For example, longer text values that include newlines often
1873       are much easier to read with vertical output:
1874
1875           mysql> SELECT * FROM mails WHERE LENGTH(txt) < 300 LIMIT 300,1\G
1876           *************************** 1. row ***************************
1877             msg_nro: 3068
1878                date: 2000-03-01 23:29:50
1879           time_zone: +0200
1880           mail_from: Jones
1881               reply: jones@example.com
1882             mail_to: "John Smith" <smith@example.com>
1883                 sbj: UTF-8
1884                 txt: >>>>> "John" == John Smith writes:
1885           John> Hi.  I think this is a good idea.  Is anyone familiar
1886           John> with UTF-8 or Unicode? Otherwise, I'll put this on my
1887           John> TODO list and see what happens.
1888           Yes, please do that.
1889           Regards,
1890           Jones
1891                file: inbox-jani-1
1892                hash: 190402944
1893           1 row in set (0.09 sec)
1894
1895       Using Safe-Updates Mode (--safe-updates)
1896
1897       For beginners, a useful startup option is --safe-updates (or
1898       --i-am-a-dummy, which has the same effect). Safe-updates mode is
1899       helpful for cases when you might have issued an UPDATE or DELETE
1900       statement but forgotten the WHERE clause indicating which rows to
1901       modify. Normally, such statements update or delete all rows in the
1902       table. With --safe-updates, you can modify rows only by specifying the
1903       key values that identify them, or a LIMIT clause, or both. This helps
1904       prevent accidents. Safe-updates mode also restricts SELECT statements
1905       that produce (or are estimated to produce) very large result sets.
1906
1907       The --safe-updates option causes mysql to execute the following
1908       statement when it connects to the MySQL server, to set the session
1909       values of the sql_safe_updates, sql_select_limit, and max_join_size
1910       system variables:
1911
1912           SET sql_safe_updates=1, sql_select_limit=1000, max_join_size=1000000;
1913
1914       The SET statement affects statement processing as follows:
1915
1916       •   Enabling sql_safe_updates causes UPDATE and DELETE statements to
1917           produce an error if they do not specify a key constraint in the
1918           WHERE clause, or provide a LIMIT clause, or both. For example:
1919
1920               UPDATE tbl_name SET not_key_column=val WHERE key_column=val;
1921               UPDATE tbl_name SET not_key_column=val LIMIT 1;
1922
1923       •   Setting sql_select_limit to 1,000 causes the server to limit all
1924           SELECT result sets to 1,000 rows unless the statement includes a
1925           LIMIT clause.
1926
1927       •   Setting max_join_size to 1,000,000 causes multiple-table SELECT
1928           statements to produce an error if the server estimates it must
1929           examine more than 1,000,000 row combinations.
1930
1931       To specify result set limits different from 1,000 and 1,000,000, you
1932       can override the defaults by using the --select-limit and
1933       --max-join-size options when you invoke mysql:
1934
1935           mysql --safe-updates --select-limit=500 --max-join-size=10000
1936
1937       It is possible for UPDATE and DELETE statements to produce an error in
1938       safe-updates mode even with a key specified in the WHERE clause, if the
1939       optimizer decides not to use the index on the key column:
1940
1941       •   Range access on the index cannot be used if memory usage exceeds
1942           that permitted by the range_optimizer_max_mem_size system variable.
1943           The optimizer then falls back to a table scan. See the section
1944           called “Limiting Memory Use for Range Optimization”.
1945
1946       •   If key comparisons require type conversion, the index may not be
1947           used (see Section 8.3.1, “How MySQL Uses Indexes”). Suppose that an
1948           indexed string column c1 is compared to a numeric value using WHERE
1949           c1 = 2222. For such comparisons, the string value is converted to a
1950           number and the operands are compared numerically (see Section 12.3,
1951           “Type Conversion in Expression Evaluation”), preventing use of the
1952           index. If safe-updates mode is enabled, an error occurs.
1953
1954       As of MySQL 8.0.13, safe-updates mode also includes these behaviors:
1955
1956       •   EXPLAIN with UPDATE and DELETE statements does not produce
1957           safe-updates errors. This enables use of EXPLAIN plus SHOW WARNINGS
1958           to see why an index is not used, which can be helpful in cases such
1959           as when a range_optimizer_max_mem_size violation or type conversion
1960           occurs and the optimizer does not use an index even though a key
1961           column was specified in the WHERE clause.
1962
1963       •   When a safe-updates error occurs, the error message includes the
1964           first diagnostic that was produced, to provide information about
1965           the reason for failure. For example, the message may indicate that
1966           the range_optimizer_max_mem_size value was exceeded or type
1967           conversion occurred, either of which can preclude use of an index.
1968
1969       •   For multiple-table deletes and updates, an error is produced with
1970           safe updates enabled only if any target table uses a table scan.
1971       Disabling mysql Auto-Reconnect
1972
1973       If the mysql client loses its connection to the server while sending a
1974       statement, it immediately and automatically tries to reconnect once to
1975       the server and send the statement again. However, even if mysql
1976       succeeds in reconnecting, your first connection has ended and all your
1977       previous session objects and settings are lost: temporary tables, the
1978       autocommit mode, and user-defined and session variables. Also, any
1979       current transaction rolls back. This behavior may be dangerous for you,
1980       as in the following example where the server was shut down and
1981       restarted between the first and second statements without you knowing
1982       it:
1983
1984           mysql> SET @a=1;
1985           Query OK, 0 rows affected (0.05 sec)
1986           mysql> INSERT INTO t VALUES(@a);
1987           ERROR 2006: MySQL server has gone away
1988           No connection. Trying to reconnect...
1989           Connection id:    1
1990           Current database: test
1991           Query OK, 1 row affected (1.30 sec)
1992           mysql> SELECT * FROM t;
1993           +------+
1994           | a    |
1995           +------+
1996           | NULL |
1997           +------+
1998           1 row in set (0.05 sec)
1999
2000       The @a user variable has been lost with the connection, and after the
2001       reconnection it is undefined. If it is important to have mysql
2002       terminate with an error if the connection has been lost, you can start
2003       the mysql client with the --skip-reconnect option.
2004
2005       For more information about auto-reconnect and its effect on state
2006       information when a reconnection occurs, see Automatic Reconnection
2007       Control[5].  mysql Client Parser Versus Server Parser
2008
2009       The mysql client uses a parser on the client side that is not a
2010       duplicate of the complete parser used by the mysqld server on the
2011       server side. This can lead to differences in treatment of certain
2012       constructs. Examples:
2013
2014       •   The server parser treats strings delimited by " characters as
2015           identifiers rather than as plain strings if the ANSI_QUOTES SQL
2016           mode is enabled.
2017
2018           The mysql client parser does not take the ANSI_QUOTES SQL mode into
2019           account. It treats strings delimited by ", ', and ` characters the
2020           same, regardless of whether ANSI_QUOTES is enabled.
2021
2022       •   Within /*! ... */ and /*+ ... */ comments, the mysql client parser
2023           interprets short-form mysql commands. The server parser does not
2024           interpret them because these commands have no meaning on the server
2025           side.
2026
2027           If it is desirable for mysql not to interpret short-form commands
2028           within comments, a partial workaround is to use the --binary-mode
2029           option, which causes all mysql commands to be disabled except \C
2030           and \d in noninteractive mode (for input piped to mysql or loaded
2031           using the source command).
2032
2034       Copyright © 1997, 2023, Oracle and/or its affiliates.
2035
2036       This documentation is free software; you can redistribute it and/or
2037       modify it only under the terms of the GNU General Public License as
2038       published by the Free Software Foundation; version 2 of the License.
2039
2040       This documentation is distributed in the hope that it will be useful,
2041       but WITHOUT ANY WARRANTY; without even the implied warranty of
2042       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2043       General Public License for more details.
2044
2045       You should have received a copy of the GNU General Public License along
2046       with the program; if not, write to the Free Software Foundation, Inc.,
2047       51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see
2048       http://www.gnu.org/licenses/.
2049
2050

NOTES

2052        1. MySQL Shell 8.0
2053           https://dev.mysql.com/doc/mysql-shell/8.0/en/
2054
2055        2. C API Basic Data Structures
2056           https://dev.mysql.com/doc/c-api/8.0/en/c-api-data-structures.html
2057
2058        3. Multiple Statement Execution Support
2059           https://dev.mysql.com/doc/c-api/8.0/en/c-api-multiple-queries.html
2060
2061        4. mysql_change_user()
2062           https://dev.mysql.com/doc/c-api/8.0/en/mysql-change-user.html
2063
2064        5. Automatic Reconnection Control
2065           https://dev.mysql.com/doc/c-api/8.0/en/c-api-auto-reconnect.html
2066

SEE ALSO

2068       For more information, please refer to the MySQL Reference Manual, which
2069       may already be installed locally and which is also available online at
2070       http://dev.mysql.com/doc/.
2071

AUTHOR

2073       Oracle Corporation (http://dev.mysql.com/).
2074
2075
2076
2077MySQL 8.0                         08/31/2023                          MYSQL(1)
Impressum