Путеводитель по Руководству Linux

  User  |  Syst  |  Libr  |  Device  |  Files  |  Other  |  Admin  |  Head  |



   mysql_embedded    ( 1 )

инструмент командной строки MariaDB (the MariaDB command-line tool)

MYSQL OPTIONS

mysql supports the following options, which can be specified on the command line or in the [mysql], [client], [client-server] or [client-mariadb] option file groups. mysql also supports the options for processing option files.

--help, -?, -I

Display a help message and exit.

--abort-source-on-error

Abort 'source filename' operations in case of errors.

--auto-rehash

Enable automatic rehashing. This option is on by default, which enables database, table, and column name completion. Use --disable-auto-rehash, --no-auto-rehash, or --skip-auto-rehash to disable rehashing. That causes mysql to start faster, but you must issue the rehash command if you want to use name completion.

To complete a name, enter the first part and press Tab. If the name is unambiguous, mysql completes 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.

--auto-vertical-output

Automatically switch to vertical output mode if the result is wider than the terminal width.

--batch, -B

Print results using tab as the column separator, with each row on a new line. With this option, mysql does 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 --raw option.

--binary-mode

By default, ASCII '\0' is disallowed and '\r\n' is translated to '\n'. This switch turns off both features, and also turns off parsing of all client commands except \C and DELIMITER, in non-interactive mode (for input piped to mysql or loaded using the 'source' command). This is necessary when processing output from mysqlbinlog that may contain blobs.

--character-sets-dir=path

The directory where character sets are installed.

--column-names

Write column names in results.

--column-type-info, -m

Display result set metadata.

--comments, -c

Whether to preserve comments in statements sent to the server. The default is --skip-comments (discard comments), enable with --comments (preserve comments).

--compress, -C

Compress all information sent between the client and the server if both support compression.

--connect-timeout=seconds

Set the number of seconds before connection timeout. (Default value is 0.)

--database=db_name, -D db_name

The database to use.

--debug[=debug_options], -# [debug_options]

Write a debugging log. A typical debug_options string is ´d:t:o,file_name´. The default is ´d:t:o,/tmp/mysql.trace´.

--debug-check

Print some debugging information when the program exits.

--debug-info, -T

Prints debugging information and memory and CPU usage statistics when the program exits.

--default-auth=name

Default authentication client-side plugin to use.

--default-character-set=charset_name

Use charset_name as the default character set for the client and connection.

A common issue that can occur when the operating system uses utf8 or another multi-byte character set is that output from the mysql client is formatted incorrectly, due to the fact that the MariaDB client uses the latin1 character set by default. You can usually fix such issues by using this option to force the client to use the system character set instead.

--defaults-extra-file=filename

Set filename as the file to read default options from after the global defaults files has been read. Must be given as first option.

--defaults-file=filename

Set filename as the file to read default options from, override global defaults files. Must be given as first option.

--defaults-group-suffix=suffix

In addition to the groups named on the command line, read groups that have the given suffix.

--delimiter=str

Set the statement delimiter. The default is the semicolon character (';').

--disable-named-commands

Disable named commands. Use the \* form only, or use named commands only at the beginning of a line ending with a semicolon (';'). mysql starts with this option enabled by default. However, even with this option, long-format commands still work from the first line. See the section called 'MYSQL COMMANDS'.

--execute=statement, -e statement

Execute the statement and quit. Disables --force and history file. The default output format is like that produced with --batch.

--force, -f

Continue even if an SQL error occurs. Sets --abort-source-on- error to 0.

--host=host_name, -h host_name

Connect to the MariaDB server on the given host.

--html, -H

Produce HTML output.

--ignore-spaces, -i

Ignore spaces after function names. Allows one to have spaces (including tab characters and new line characters) between function name and '('. The drawback is that this causes built in functions to become reserved words.

--init-command=str

SQL Command to execute when connecting to the MariaDB server. Will automatically be re-executed when reconnecting.

--line-numbers

Write line numbers for errors. Disable this with --skip-line-numbers.

--local-infile[={0|1}]

Enable or disable LOCAL capability for LOAD DATA INFILE. With no value, the option enables LOCAL. The option may be given as --local-infile=0 or --local-infile=1 to explicitly disable or enable LOCAL. Enabling LOCAL has no effect if the server does not also support it.

--max-allowed-packet=num

Set the maximum packet length to send to or receive from the server. (Default value is 16MB, largest 1GB.)

--max-join-size=num

Set the automatic limit for rows in a join when using --safe-updates. (Default value is 1,000,000.)

--named-commands, -G

Enable named mysql commands. Long-format commands are allowed, not just short-format commands. For example, quit and \q both are recognized. Use --skip-named-commands to disable named commands. See the section called 'MYSQL COMMANDS'. Disabled by default.

•• --net-buffer-length=size

Set the buffer size for TCP/IP and socket communication. (Default value is 16KB.)

--no-auto-rehash, -A

This has the same effect as --skip-auto-rehash. See the description for --auto-rehash.

--no-beep, -b

Do not beep when errors occur.

--no-defaults

Do not read default options from any option file. This must be given as the first argument.

--one-database, -o

Ignore statements except those those that occur while the default database is the one named on the command line. This filtering is limited, and based only on USE statements. This is useful for skipping updates to other databases in the binary log.

--pager[=command]

Use the given command for paging query output. If the command is omitted, the default pager is the value of your PAGER environment variable. Valid pagers are less, more, cat [> filename], and so forth. This option works only on Unix and only in interactive mode. To disable paging, use --skip-pager. the section called 'MYSQL COMMANDS', discusses output paging further.

--password[=password], -p[password]

The password to use when connecting to the server. If you use the short option form (-p), you cannot have a space between the option and the password. If you omit the password value following the --password or -p option on the command line, mysql prompts for one.

Specifying a password on the command line should be considered insecure. You can use an option file to avoid giving the password on the command line.

--pipe, -W

On Windows, connect to the server via a named pipe. This option applies only if the server supports named-pipe connections.

--plugin-dir=dir_name

Directory for client-side plugins.

--port=port_num, -P port_num

The TCP/IP port number to use for the connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, /etc/services, built-in default (3306). Forces --protocol=tcp when specified on the command line without other connection properties.

--print-defaults

Print the program argument list and exit. This must be given as the first argument.

--progress-reports

Get progress reports for long running commands (such as ALTER TABLE). (Defaults to on; use --skip-progress-reports to disable.)

--prompt=format_str

Set the prompt to the specified format. The special sequences that the prompt can contain are described in the section called 'MYSQL COMMANDS'.

--protocol={TCP|SOCKET|PIPE|MEMORY}

The connection protocol to use for connecting to the server. It is useful when the other connection parameters normally would cause a protocol to be used other than the one you want.

--quick, -q

Do not cache each query result, print each row as it is received. This may slow down the server if the output is suspended. With this option, mysql does not use the history file.

--raw, -r

For tabular output, the 'boxing' around columns enables one column value to be distinguished from another. For nontabular output (such as is produced in batch mode or when the --batch or --silent option is given), special characters are escaped in the output so they can be identified easily. Newline, tab, NUL, and backslash are written as \n, \t, \0, and \\. The --raw option disables this character escaping.

The following example demonstrates tabular versus nontabular output and the use of raw mode to disable escaping:

% mysql mysql> SELECT CHAR(92); +----------+ | CHAR(92) | +----------+ | \ | +----------+ % mysql -s mysql> SELECT CHAR(92); CHAR(92) \\ % mysql -s -r mysql> SELECT CHAR(92); CHAR(92) \

--reconnect

If the connection to the server is lost, automatically try to reconnect. A single reconnect attempt is made each time the connection is lost. Enabled by default, to disable use --skip-reconnect or --disable-reconnect.

--safe-updates, --i-am-a-dummy, -U

Allow only those UPDATE and DELETE statements that specify which rows to modify by using key values. If you have set this option in an option file, you can override it by using --safe-updates on the command line. See the section called 'MYSQL TIPS', for more information about this option.

--secure-auth

Do not send passwords to the server in old (pre-4.1.1) format. This prevents connections except for servers that use the newer password format.

--select-limit=limit

Set automatic limit for SELECT when using --safe-updates. (Default value is 1,000.)

--server-arg=name

Send name as a parameter to the embedded server.

--show-warnings

Cause warnings to be shown after each statement if there are any. This option applies to interactive and batch mode.

--sigint-ignore

Ignore SIGINT signals (typically the result of typing Control-C).

--silent, -s

Silent mode. Produce less output. This option can be given multiple times to produce less and less output.

This option results in nontabular output format and escaping of special characters. Escaping may be disabled by using raw mode; see the description for the --raw option.

--skip-auto-rehash

Disable automatic rehashing. Synonym for --disable-auto-rehash.

--skip-column-names, -N

Do not write column names in results.

--skip-line-numbers, -L

Do not write line numbers for errors. Useful when you want to compare result files that include error messages.

--socket=path, -S path

For connections to localhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use. Forces --protocol=socket when specified on the command line without other connection properties; on Windows, forces --protocol=pipe.

--ssl

Enable SSL for connection (automatically enabled with other flags). Disable with --skip-ssl.

--ssl-ca=name

CA file in PEM format (check OpenSSL docs, implies --ssl).

--ssl-capath=name

CA directory (check OpenSSL docs, implies --ssl).

--ssl-cert=name

X509 cert in PEM format (check OpenSSL docs, implies --ssl).

--ssl-cipher=name

SSL cipher to use (check OpenSSL docs, implies --ssl).

--ssl-key=name

X509 key in PEM format (check OpenSSL docs, implies --ssl).

--ssl-crl=name

Certificate revocation list (check OpenSSL docs, implies --ssl).

--ssl-crlpath=name

Certificate revocation list path (check OpenSSL docs, implies --ssl).

--ssl-verify-server-cert

Verify server's "Common Name" in its cert against hostname used when connecting. This option is disabled by default.

--table, -t

Display output in table format. This is the default for interactive use, but can be used to produce table output in batch mode.

--tee=file_name

Append a copy of output to the given file. This option works only in interactive mode. the section called 'MYSQL COMMANDS', discusses tee files further.

--unbuffered, -n

Flush the buffer after each query.

--user=user_name, -u user_name

The MariaDB user name to use when connecting to the server.

--verbose, -v

Verbose mode. Produce more output about what the program does. This option can be given multiple times to produce more and more output. (For example, -v -v -v produces table output format even in batch mode.)

--version, -V

Display version information and exit.

--vertical, -E

Print query output rows vertically (one line per column value). Without this option, you can specify vertical output for individual statements by terminating them with \G.

--wait, -w

If the connection cannot be established, wait and retry instead of aborting.

--xml, -X

Produce XML output. The output when --xml is used with mysql matches that of mysqldump --xml. See mysqldump(1) for details.

The XML output also uses an XML namespace, as shown here:

shell> mysql --xml -uroot -e "SHOW VARIABLES LIKE ´version%´" <?xml version="1.0"?> <resultset statement="SHOW VARIABLES LIKE ´version%´" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <row> <field name="Variable_name">version</field> <field name="Value">5.0.40-debug</field> </row> <row> <field name="Variable_name">version_comment</field> <field name="Value">Source distribution</field> </row> <row> <field name="Variable_name">version_compile_machine</field> <field name="Value">i686</field> </row> <row> <field name="Variable_name">version_compile_os</field> <field name="Value">suse-linux-gnu</field> </row> </resultset>

You can also set the following variables by using --var_name=value.

• connect_timeout

The number of seconds before connection timeout. (Default value is 0.)

• max_allowed_packet

The maximum packet length to send to or receive from the server. (Default value is 16MB.)

• max_join_size

The automatic limit for rows in a join when using --safe-updates. (Default value is 1,000,000.)

• net_buffer_length

The buffer size for TCP/IP and socket communication. (Default value is 16KB.)

• select_limit

The automatic limit for SELECT statements when using --safe-updates. (Default value is 1,000.)

On Unix, the mysql client writes a record of executed statements to a history file. By default, this file is named .mysql_history and is created in your home directory. To specify a different file, set the value of the MYSQL_HISTFILE environment variable.

The .mysql_history should be protected with a restrictive access mode because sensitive information might be written to it, such as the text of SQL statements that contain passwords.

If you do not want to maintain a history file, first remove .mysql_history if it exists, and then use either of the following techniques:

• Set the MYSQL_HISTFILE variable to /dev/null. To cause this setting to take effect each time you log in, put the setting in one of your shell´s startup files.

• Create .mysql_history as a symbolic link to /dev/null:

shell> ln -s /dev/null $HOME/.mysql_history

You need do this only once.