"Fossies" - the Fresh Open Source Software Archive

Member "refman-8.0-en.man-gpl/mysqlsh.1" (25 Oct 2021, 38483 Bytes) of package /linux/misc/mysql-refman/mysql-refman-8.0-en.man-gpl.tar.gz:


Caution: As a special service "Fossies" has tried to format the requested manual source page into HTML format but links to other man pages may be missing or even erroneous. Alternatively you can here view or download the uninterpreted manual source code. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.

MYSQLSH

NAME
SYNOPSIS
DESCRIPTION
COPYRIGHT
NOTES
AUTHOR

NAME

mysqlsh − the MySQL shell

SYNOPSIS

mysqlsh [options] db_name

DESCRIPTION

MySQL Shell is an advanced command−line client and code editor for MySQL. In addition to SQL, MySQL Shell also offers scripting capabilities for JavaScript and Python. For information about using MySQL Shell, see MySQL Shell 8.0. When MySQL Shell is connected to the MySQL Server through the X Protocol, the X DevAPI can be used to work with both relational and document data, see Using MySQL as a Document Store [1] . MySQL Shell includes the AdminAPI that enables you to work with InnoDB Cluster; see Chapter 6, MySQL AdminAPI.

Many of the options described here are related to connections between MySQL Shell and a MySQL Server instance. See Section 4.3, “MySQL Shell Connections” for more information.

mysqlsh supports the following command−line options.

−−help, −?

Display a help message and exit.

−−

Marks the end of the list of mysqlsh options and the start of a command and its arguments for MySQL Shell's API command line integration. You can execute methods of the MySQL Shell global objects from the command line using this syntax:

mysqlsh [options] −− object method [arguments]

See Section 5.8, “API Command Line Integration” for more information.

−−auth−method=method

Authentication method to use for the account. Depends on the authentication plugin used for the account's password. For MySQL Shell connections using classic MySQL protocol, specify the name of the authentication plugin, for example caching_sha2_password. For MySQL Shell connections using X Protocol, specify one of the following options:

AUTO

Let the library select the authentication method.

FALLBACK

Let the library select the authentication method, but do not use any authentication method that is not compatible with MySQL 5.7.

FROM_CAPABILITIES

Let the library select the authentication method, using the capabilities announced by the server instance.

MYSQL41

Use the challenge−response authentication protocol supported by MySQL 4.1 and later, which does not send a plaintext password. This option is compatible with accounts that use the mysql_native_password authentication plugin.

PLAIN

Send a plaintext password for authentication. Use this option only wih encrypted connections. This option can be used to authenticate with cached credentials for an account that uses the caching_sha2_password authentication plugin, provided there is an SSL connection. See Using X Plugin with the Caching SHA−2 Authentication Plugin [2] .

SHA256_MEMORY

Authenticate using a hashed password stored in memory. This option can be used to authenticate with cached credentials for an account that uses the caching_sha2_password authentication plugin, where there is a non−SSL connection. See Using X Plugin with the Caching SHA−2 Authentication Plugin [2] .

−−cluster

Ensures that the target server is part of an InnoDB Cluster and if so, sets the cluster global variable to the cluster object.

−−column−type−info

In SQL mode, before printing the returned result set for a query, print metadata for each column in the result set, such as the column type and collation.

The column type is returned as both the type used by MySQL Shell (Type), and the type used by the original database (DBType). For MySQL Shell connections using classic MySQL protocol, DBType is as returned by the protocol, and for X Protocol connections, DBType is inferred from the available information. The column length (Length) is returned in bytes.

−−compress[={required|preferred|disabled}], −C [{required|preferred|disabled}]

Controls compression of information sent between the client and the server using this connection. In MySQL Shell 8.0.14 through 8.0.19 this option is available for classic MySQL protocol connections only, and does not use the options required, preferred, and disabled. In those releases, when you specify −−compress, compression is activated if possible. From MySQL Shell 8.0.20 it is also available for X Protocol connections, and you can optionally specify required, preferred, or disabled. When just −−compress is specified from MySQL Shell 8.0.20, the meaning is −−compress=required. See Section 4.3.4, “Using Compressed Connections” for information on using MySQL Shell's compression control in all releases.

−−connect−timeout=ms

Configures how long MySQL Shell waits (in milliseconds) to establish a global session specified through command−line arguments.

−−credential−store−helper=helper

The Secret Store Helper that is to be used to store and retrieve passwords. See Section 4.4, “Pluggable Password Store”.

−−database=name, −D name

The default schema to use. This is an alias for −−schema.

−−dba=enableXProtocol

Enable X Plugin on connection with a MySQL 5.7 server, so that you can use X Protocol connections for subsequent connections. Requires a connection using classic MySQL protocol. Not relevant for MySQL 8.0 servers, which have X Plugin enabled by default.

−−dba−log−sql[=0|1|2]

Log SQL statements that are executed by AdminAPI operations (excluding sandbox operations). By default, this category of statement is not written to the MySQL Shell application log file or sent to the console as verbose output, even when the −−log−level and −−verbose options are set. The value of the option is an integer in the range from 0 to 2. 0 does not log or display this category of statement, which is the default behavior if you do not specify the option. 1 logs SQL statements that are executed by AdminAPI operations, with the exceptions of SELECT statements and SHOW statements (this is the default setting if you specify the option on the command line without a value). 2 logs SQL statements that are executed by regular AdminAPI operations in full, including SELECT and SHOW statements. See Chapter 11, MySQL Shell Logging and Debug for more information.

−−dbpassword[=password]

Deprecated in version 8.0.13 of MySQL Shell. Use −−password[=password] instead.

−−dbuser=user_name

Deprecated in version 8.0.13 of MySQL Shell. Use −−user=user_name instead.

−−execute=command, −e command

Execute the command using the currently active language and quit. This option is mutually exclusive with the −−file=file_name option.

−−file=file_name, −f file_name

Specify a file to process in Batch mode. Any options specified after this are used as arguments of the processed file.

−−force

Continue processing in SQL and Batch modes even if errors occur.

−−histignore=strings

Specify strings that are not added to the MySQL Shell history. Strings are separated by a colon. Matching is case insensitive, and the wildcards * and ? can be used. The default ignored strings are specified as “*IDENTIFIED*:*PASSWORD*”. See Section 5.5, “Code History”.

−−host=host_name, −h host_name

Connect to the MySQL server on the given host. On Windows, if you specify −−host=. or −h . (giving the host name as a period), MySQL Shell connects using the default named pipe (which has the name MySQL), or an alternative named pipe that you specify using the −−socket option.

−−get−server−public−key

MySQL Shell equivalent of −−get−server−public−key.

If −−server−public−key−path=file_name is given and specifies a valid public key file, it takes precedence over −−get−server−public−key.

Important
Only supported with classic MySQL protocol connections.

See Caching SHA−2 Pluggable Authentication [3] .

−−import

Import JSON documents from a file or standard input to a MySQL Server collection or relational table, using the JSON import utility. For instructions, see Section 10.2, “JSON Import Utility”.

−−interactive[=full], −i

Emulate Interactive mode in Batch mode.

−−js, −−javascript

Start in JavaScript mode.

−−json[={off|pretty|raw}]

Controls JSON wrapping for MySQL Shell output from this session. This option is intended for interfacing MySQL Shell with other programs, for example as part of testing. For changing query results output to use the JSON format, see −−result−format.

When the −−json option has no value or a value of pretty, the output is generated as pretty−printed JSON. With a value of raw, the output is generated in raw JSON format. In any of these cases, the −−result−format option and its aliases and the value of the resultFormat MySQL Shell configuration option are ignored. With a value of off, JSON wrapping does not take place, and result sets are output as normal in the format specified by the −−result−format option or the resultFormat configuration option.

−−log−level=N

Change the logging level for the MySQL Shell application log file, or disable logging to the file. The option requires a value, which can be either an integer in the range from 1 to 8, or one of none, internal, error, warning, info, debug, debug2, or debug3. Specifying 1 or none disables logging to the application log file. Level 5 (info) is the default if you do not specify this option. See Chapter 11, MySQL Shell Logging and Debug.

−ma

Deprecated in version 8.0.13 of MySQL Shell. Automatically attempts to use X Protocol to create the session's connection, and falls back to classic MySQL protocol if X Protocol is unavailable.

−−mysql, −−mc

Sets the global session created at start up to to use a classic MySQL protocol connection. The −−mc option with two hyphens replaces the previous single hyphen −mc option from MySQL Shell 8.0.13.

−−mysqlx, −−mx

Sets the global session created at start up to use an X Protocol connection. The −−mx option with two hyphens replaces the previous single hyphen −mx option from MySQL Shell 8.0.13.

−−name−cache

Enable automatic loading of table names based on the active default schema.

−−no−name−cache, −A

Disable loading of table names for autocompletion based on the active default schema and the DevAPI db object. Use \rehash to reload the name information manually.

−−no−password

When connecting to the server, if the user has a passwordless account, which is insecure and not recommended, or if socket peer−credential authentication is in use (for Unix socket connections), you must use −−no−password to explicitly specify that no password is provided and the password prompt is not required.

−−no−wizard, −nw

Disables the interactive wizards provided by operations such as creating connections, dba.configureInstance(), Cluster.rebootClusterFromCompleteOutage() and so on. Use this option when you want to script MySQL Shell and not have the interactive prompts displayed. For more information see Section 5.6, “Batch Code Execution” and Section 5.8, “API Command Line Integration”.

−−pager=name

The external pager tool used by MySQL Shell to display text output for statements executed in SQL mode and other selected commands such as online help. If you do not set a pager, the pager specified by the PAGER environment variable is used. See Section 4.6, “Using a Pager”.

−−passwords−from−stdin

Read the password from standard input, rather than from the terminal. This option does not affect any other password behaviors, such as the password prompt.

−−password[=password], −ppassword

The password to use when connecting to the server. The maximum password length that is accepted for connecting to MySQL Shell is 128 characters.

−−password=password (−ppassword) with a value supplies a password to be used for the connection. With the long form −−password=, you must use an equals sign and not a space between the option and its value. With the short form −p, there must be no space between the option and its value. If a space is used in either case, the value is not interpreted as a password and might be interpreted as another connection parameter.

Specifying a password on the command line should be considered insecure. See End−User Guidelines for Password Security [4] . You can use an option file to avoid giving the password on the command line.

−−password with no value and no equal sign, or −p without a value, requests the password prompt.

−−password= with an empty value has the same effect as −−no−password, which specifies that the user is connecting without a password. When connecting to the server, if the user has a passwordless account, which is insecure and not recommended, or if socket peer−credential authentication is in use (for Unix socket connections), you must use one of these methods to explicitly specify that no password is provided and the password prompt is not required.

−−port=port_num, −P port_num

The TCP/IP port number to use for the connection. The default is port 33060.

−−py, −−python

Start in Python mode.

−−pym

Execute the specified Python module as a script in MySQL Shell's Python mode. −−pym works in the same way as Python's −m command line option. This option is available from MySQL Shell 8.0.22.

−−quiet−start[=1|2]

Start without printing introductory information. MySQL Shell normally prints information about the product, information about the session (such as the default schema and connection ID), warning messages, and any errors that are returned during startup and connection. When you specify −−quiet−start with no value or a value of 1, information about the MySQL Shell product is not printed, but session information, warnings, and errors are printed. With a value of 2, only errors are printed.

−−recreate−schema

Drop and recreate the schema that was specified in the connection options, either as part of a URI−like connection string or using the −−schema, −−database, or −D option. The schema is deleted if it exists.

−−redirect−primary

Ensures that the target server is part of an InnoDB Cluster or InnoDB ReplicaSet and if it is not the primary, finds the primary and connects to it. MySQL Shell exits with an error if any of the following is true when using this option:

• No instance is specified

• On an InnoDB Cluster, Group Replication is not active

• InnoDB Cluster metadata does not exist

• There is no quorum

−−replicaset

Ensures that the target server belongs to an InnoDB ReplicaSet, and if so, populates the rs global variable with the InnoDB ReplicaSet. You can then administer the InnoDB ReplicaSet using the rs global variable, for example by issuing rs.status().

−−redirect−secondary

Ensures that the target server is part of a single−primary InnoDB Cluster or InnoDB ReplicaSet and if it is not a secondary, finds a secondary and connects to it. MySQL Shell exits with an error if any of the following is true when using this option:

• On an InnoDB Cluster, Group Replication is not active

• InnoDB Cluster metadata does not exist

• There is no quorum

• The cluster is not single−primary and is running in multi−primary mode

• There is no secondary available, for example because there is just one server instance

−−result−format={table|tabbed|vertical|json|json/pretty|ndjson|json/raw|json/array}

Set the value of the resultFormat MySQL Shell configuration option for this session. Formats are as follows:

table

The default for interactive mode, unless another value has been set persistently for the resultFormat configuration option in the configuration file, in which case that default applies. The −−table alias can also be used.

tabbed

The default for batch mode, unless another value has been set persistently for the resultFormat configuration option in the configuration file, in which case that default applies. The −−tabbed alias can also be used.

vertical

Produces output equivalent to the \G terminator for an SQL query. The −−vertical or −E aliases can also be used.

json or json/pretty

Produces pretty−printed JSON.

ndjson or json/raw

Produces raw JSON delimited by newlines.

json/array

Produces raw JSON wrapped in a JSON array.

If the −−json command line option is used to activate JSON wrapping for output for the session, the −−result−format option and its aliases and the value of the resultFormat configuration option are ignored.

−−save−passwords={always|prompt|never}

Controls whether passwords are automatically stored in the secret store. always means passwords are always stored unless they are already in the store or the server URL is excluded by a filter. never means passwords are never stored. prompt, which is the default, means users are asked whether to store the password or not. See Section 4.4, “Pluggable Password Store”.

−−schema=name, −D name

The default schema to use.

−−server−public−key−path=file_name

MySQL Shell equivalent of −−server−public−key−path.

If −−server−public−key−path=file_name is given and specifies a valid public key file, it takes precedence over −−get−server−public−key.

Important
Only supported with classic MySQL protocol connections.

See caching_sha2_password plugin Caching SHA−2 Pluggable Authentication [3] .

−−show−warnings={true|false}

When true is specified, which is the default, in SQL mode, MySQL Shell displays warnings after each SQL statement if there are any. If false is specified, warning are not displayed.

−−socket[=path], −S [path]

On Unix, when a path is specified, the path is the name of the Unix socket file to use for the connection. If you specify −−socket with no value and no equal sign, or −S without a value, the default Unix socket file for the appropriate protocol is used.

On Windows, the path is the name of the named pipe to use for the connection. The pipe name is not case−sensitive. On Windows, you must specify a path, and the −−socket option is available for classic MySQL protocol sessions only.

You cannot specify a socket if you specify a port or a host name other than localhost on Unix or a period (.) on Windows.

−−sql

Start in SQL mode, auto−detecting the protocol to use if it is not specified as part of the connection information. When the protocol to use is not specified, defaults to an X Protocol connection, falling back to a classic MySQL protocol connection. To force a connection to use a specific protocol see the −−sqlx or −−sqlc options. Alternatively, specify a protocol to use as part of a URI−like connection string or use the −−port option. See Section 4.3, “MySQL Shell Connections” and MySQL Shell Ports [5] for more information.

−−sqlc

Start in SQL mode forcing the connection to use classic MySQL protocol, for example to use MySQL Shell with a server that does not support X Protocol. If you do not specify the port as part of the connection, when you provide this option MySQL Shell uses the default classic MySQL protocol port which is usually 3306. The port you are connecting to must support classic MySQL protocol, so for example if the connection you specify uses the X Protocol default port 33060, the connection fails with an error. See Section 4.3, “MySQL Shell Connections” and MySQL Shell Ports [5] for more information.

−−sqlx

Start in SQL mode forcing the connection to use X Protocol. If you do not specify the port as part of the connection, when you provide this option MySQL Shell uses the default X Protocol port which is usually 33060. The port you are connecting to must support X Protocol, so for example if the connection you specify uses the classic MySQL protocol default port 3306, the connection fails with an error. See Section 4.3, “MySQL Shell Connections” and MySQL Shell Ports [5] for more information.

−−ssl*

Options that begin with −−ssl specify whether to connect to the server using SSL and indicate where to find SSL keys and certificates. The mysqlsh SSL options function in the same way as the SSL options for MySQL Server, see Command Options for Encrypted Connections [6] for more information.

mysqlsh accepts these SSL options: −−ssl−mode, −−ssl−ca, −−ssl−capath, −−ssl−cert, −−ssl−cipher, −−ssl−crl, −−ssl−crlpath, −−ssl−key, −−tls−version.

−−syslog

Send SQL statements that you issue in MySQL Shell’s SQL mode to the operating system’s system logging facility (syslog on Unix, or the Windows Event Log). System logging for SQL statements only takes place when MySQL Shell is started in interactive mode, so either a normal start or a start with the −−interactive option. It does not take place if the −−execute or −−file options are used at startup to run mysqlsh in batch mode. See Section 11.3, “System Logging for SQL Statements” for more information.

−−tabbed

Display results in tab separated format in interactive mode. The default for that mode is table format. This option is an alias of the −−result−format=tabbed option.

−−table

Display results in table format in batch mode. The default for that mode is tab separated format. This option is an alias of the −−result−format=table option.

−−uri=str

Create a connection upon startup, specifying the connection options in a URI−like string as described at Connecting to the Server Using URI−Like Strings or Key−Value Pairs [7] .

−−user=user_name, −u user_name

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

−−verbose[=0|1|2|3|4]

Activate verbose output to the console and specify the level of detail. The value is an integer in the range from 0 to 4. 0 displays no messages, which is the default verbosity setting when you do not specify the option. 1 displays error, warning and informational messages (this is the default setting if you specify the option on the command line without a value). 2, 3, and 4 add higher levels of debug messages. See Chapter 11, MySQL Shell Logging and Debug for more information.

−−version, −V

Display the version of MySQL Shell and exit.

−−vertical, −E

Display results vertically, as when the \G terminator is used for an SQL query. This option is an alias of the −−result−format=vertical option.

COPYRIGHT

Copyright © 2006, 2021, Oracle and/or its affiliates.

This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.

This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see http://www.gnu.org/licenses/.

NOTES

1.

Using MySQL as a Document Store

https://dev.mysql.com/doc/refman/8.0/en/document-store.html

2.

Using X Plugin with the Caching SHA-2 Authentication Plugin

https://dev.mysql.com/doc/refman/8.0/en/x-plugin-sha2-cache-plugin.html

3.

Caching SHA-2 Pluggable Authentication

https://dev.mysql.com/doc/refman/8.0/en/caching-sha2-pluggable-authentication.html

4.

End-User Guidelines for Password Security

https://dev.mysql.com/doc/refman/8.0/en/password-security-user.html

5.

MySQL Shell Ports

https://dev.mysql.com/doc/mysql-port-reference/en/mysql-ports-reference-tables.html#mysql-shell-ports

6.

Command Options for Encrypted Connections

https://dev.mysql.com/doc/refman/8.0/en/connection-options.html#encrypted-connection-options

7.

Connecting to the Server Using URI-Like Strings or Key-Value Pairs

https://dev.mysql.com/doc/refman/8.0/en/connecting-using-uri-or-key-value-pairs.html

AUTHOR

Oracle Corporation (http://dev.mysql.com/).