mysql (1) Linux Manual Page
NAME
mysql – the MySQL command-line client
SYNOPSIS
-
mysql [options]db_name
DESCRIPTION
mysql
If you have problems due to insufficient memory for large result sets, use the –quick option. This forces mysql to retrieve results from the server a row at a time rather than retrieving the entire result set and buffering it in memory before displaying it. This is done by returning the result set using the mysql_use_result() C API function in the client/server library rather than mysql_store_result().
-
NoteAlternatively, MySQL Shell offers access to the X DevAPI. For details, see m[blue]
MySQL Shell 8.0 (part of MySQL 8.0)m[][1].
Using mysql is very easy. Invoke it from the prompt of your command interpreter as follows:
-
shell>
mysqldb_name
Or:
-
shell>
mysql --user=user_name--passworddb_name Enter password: your_password
Then type an SQL statement, end it with ;, \g, or \G and press Enter.
Typing Control+C interrupts the current statement if there is one, or cancels any partial input line otherwise.
You can execute SQL statements in a script file (batch file) like this:
-
shell>
mysqldb_name<script.sql>output.tab
On Unix, the mysql client logs statements executed interactively to a history file. See the section called “MYSQL CLIENT LOGGING”.
MYSQL CLIENT OPTIONS
mysql supports the following options, which can be specified on the command line or in the [mysql] and [client] groups of an option file. For information about option files used by MySQL programs, see Section 4.2.2.2, “Using Option Files”.
- •
–help,-?Display a help message and exit.
- •
–auto-rehashEnable automatic rehashing. This option is on by default, which enables database, table, and column name completion. Use
–disable-auto-rehashto disable rehashing. That causesmysqlto start faster, but you must issue the rehash command or its \# shortcut if you want to use name completion.To complete a name, enter the first part and press Tab. If the name is unambiguous,
mysqlcompletes it. Otherwise, you can press Tab again to see the possible names that begin with what you have typed so far. Completion does not occur if there is no default database.-
Note
This feature requires a MySQL client that is compiled with thereadlinelibrary. Typically, thereadlinelibrary is not available on Windows.
- •
–auto-vertical-outputCause result sets to be displayed vertically if they are too wide for the current window, and using normal tabular format otherwise. (This applies to statements terminated by ; or \G.)
- •
–batch,-BPrint results using tab as the column separator, with each row on a new line. With this option,
mysqldoes not use the history file.Batch mode results in nontabular output format and escaping of special characters. Escaping may be disabled by using raw mode; see the description for the
–rawoption.
- •
–binary-as-hexWhen this option is given,
mysqldisplays binary data using hexadecimal notation (0xvalue). This occurs whether the overall output dislay format is tabular, vertical, HTML, or XML.As of MySQL 8.0.19, when
mysqloperates in interactive mode, this option is enabled by default. In addition, output from the status (or \s) command includes this line when the option is enabled implicitly or explicitly:-
Binary data as: Hexadecimal
To disable hexadecimal notation, use
–skip-binary-as-hex
- •
–binary-modeThis option helps when processing
mysqlbinlogoutput that may contain BLOB values. By default,mysqltranslates
in statement strings to
and interprets
