MySQL Shell is updated frequently with fixes and new features. It is strongly recommended that you always use the most recent version available. The latest version of MySQL Shell can be used with any version of MySQL 5.7 or 8.0.
The following features are available in MySQL Shell.
Any executed code is processed as one of these languages, based on
the language that is currently active. There are also specific
MySQL Shell commands, prefixed with
enable you to configure MySQL Shell regardless of the currently
selected language. For more information see
Section 3.1, “MySQL Shell Commands”.
From version 8.0.18, MySQL Shell uses Python 3, rather than Python 2.7. For platforms that include a system supported installation of Python 3, MySQL Shell uses the most recent version available, with a minimum supported version of Python 3.6. For platforms where Python 3 is not included or is not at the minimum supported version, MySQL Shell bundles Python 3.7.7 up to MySQL Shell 8.0.25, and Python 3.9.5 from MySQL Shell 8.0.26. MySQL Shell maintains code compatibility with Python 2.6 and Python 2.7, so if you require one of these older versions, you can build MySQL Shell from source using the appropriate Python version.
As of 8.0.32, MySQL Shell bundles Python 3.10.8 for platforms where Python 3 is not included or is not at the minimum supported version.
This is true for all builds except Oracle Linux 7, which bundles Python 3.9.15
MySQL Shell provides an interactive code execution mode, where you type code at the MySQL Shell prompt and each entered statement is processed, with the result of the processing printed onscreen. Unicode text input is supported if the terminal in use supports it. Color terminals are supported.
Multiple-line code can be written using a command, enabling MySQL Shell to cache multiple lines and then execute them as a single statement. For more information see Multiple-line Support.
In addition to the interactive execution of code, MySQL Shell can also take code from different sources and process it. This method of processing code in a noninteractive way is called Batch Execution.
As batch execution mode is intended for script processing of a
single language, it is limited to having minimal non-formatted
output and disabling the execution of commands. To avoid these
limitations, use the
command-line option, which tells MySQL Shell to execute the input
as if it were an interactive session. In this mode the input is
processed line by line just as if each line
were typed in an interactive session. For more information see
Section 5.6, “Batch Code Execution”.
AdminAPI enables you to administer MySQL instances, using them to create InnoDB Cluster, InnoDB ClusterSet, and InnoDB ReplicaSet deployments, and integrating MySQL Router.
InnoDB Cluster provides an integrated solution for high availability and scalability using InnoDB based MySQL databases. InnoDB Cluster is an alternative solution for using Group Replication, without requiring advanced MySQL expertise. See Chapter 7, MySQL InnoDB Cluster.
InnoDB ClusterSet provides disaster tolerance for Chapter 7, MySQL InnoDB Cluster deployments by linking a primary InnoDB Cluster with one or more replicas of itself in alternate locations. See Chapter 8, MySQL InnoDB ClusterSet.
InnoDB ReplicaSet enables you to administer a set of MySQL instances running asynchronous GTID-based replication. See Chapter 9, MySQL InnoDB ReplicaSet.
AdminAPI also provides operations to configure users for MySQL Router, to make integration with InnoDB Cluster, InnoDB ClusterSet, and InnoDB ReplicaSet as simple as possible. For more information on AdminAPI, see Chapter 6, MySQL AdminAPI.
X DevAPI enables developers to work with both relational and document data when MySQL Shell is connected to a MySQL server using the X Protocol. For more information, see Using MySQL as a Document Store. For documentation on the concepts and usage of X DevAPI, see X DevAPI User Guide.
MySQL Shell is designed to provide an integrated command-line client for all MySQL products which support X Protocol. The development features of MySQL Shell are designed for sessions using the X Protocol. MySQL Shell can also connect to MySQL Servers that do not support the X Protocol using the classic MySQL protocol. A minimal set of features from the X DevAPI are available for sessions created using the classic MySQL protocol.
MySQL Shell includes the following utilities for working with MySQL:
An upgrade checker utility to verify whether MySQL server instances are ready for upgrade. Use
util.checkForServerUpgrade()to access the upgrade checker.
A JSON import utility to import JSON documents to a MySQL Server collection or table. Use
util.importJSON()to access the import utility.
A parallel table import utility that splits up a single data file and uses multiple threads to load the chunks into a MySQL table.
See Chapter 11, MySQL Shell Utilities for more information.
MySQL Shell exposes much of its functionality using an API
command syntax that enables you to easily integrate
mysqlsh with other tools. For example you can
create bash scripts which administer an
InnoDB Cluster with this functionality. Use the
pass operations directly to MySQL Shell global objects, bypassing
the REPL interface. See
Section 5.8, “API Command Line Integration”.
MySQL Shell can return results in table, tabbed, or vertical format, or as JSON output. To help integrate MySQL Shell with external tools, you can activate JSON wrapping for all output when you start MySQL Shell from the command line. For more information see Section 5.7, “Output Formats”.
MySQL Shell can log information about the execution process at your chosen level of detail. Logging information can be sent to any combination of an application log file, an additional viewable destination, and the console. For more information see Chapter 12, MySQL Shell Logging and Debug.
In MySQL Shell, connections to MySQL Server instances are handled
by a session object. When you make the first connection to a MySQL
Server instance, which can be done either while starting
MySQL Shell or afterwards, a MySQL Shell global object named
session is created to represent this
connection. This session is known as the global session because it
can be used in all of the MySQL Shell execution modes. In SQL
mode the global session is used for executing statements, and in
session. You can create further session
objects using functions available in the
you can set one of these session objects as the
session global object so you can use it in any
mode. For more information, see
Section 4.2, “MySQL Shell Sessions”.