MySQL Shell 8.0

Abstract

MySQL Shell is an advanced client and code editor for MySQL. This document describes the core features of MySQL Shell. In addition to the provided SQL functionality, similar to mysql, MySQL Shell provides scripting capabilities for JavaScript and Python and includes APIs for working with MySQL. X DevAPI enables you to work with both relational and document data, see Using MySQL as a Document Store. AdminAPI enables you to work with InnoDB Cluster, see Chapter 6, MySQL AdminAPI.

MySQL Shell 8.0 is highly recommended for use with MySQL Server 8.0 and 5.7. Please upgrade to MySQL Shell 8.0. If you have not yet installed MySQL Shell, download it from the download site.

For notes detailing the changes in each release, see the MySQL Shell Release Notes.

For help with using MySQL, please visit the MySQL Forums, where you can discuss your issues with other MySQL users.

Licensing information.  This product may include third-party software, used under license. If you are using a Commercial release of MySQL Shell, see MySQL Shell Commercial License Information User Manual for licensing information, including licensing information relating to third-party software that may be included in this Commercial release. If you are using a Community release of MySQL Shell, see MySQL Shell Community License Information User Manual for licensing information, including licensing information relating to third-party software that may be included in this Community release.

Document generated on: 2021-09-22 (revision: 70868)

Table of Contents

1 MySQL Shell Features
2 Installing MySQL Shell
2.1 Installing MySQL Shell on Microsoft Windows
2.2 Installing MySQL Shell on Linux
2.3 Installing MySQL Shell on macOS
3 Using MySQL Shell Commands
3.1 MySQL Shell Commands
4 Getting Started with MySQL Shell
4.1 Starting MySQL Shell
4.2 MySQL Shell Sessions
4.2.1 Creating the Session Global Object While Starting MySQL Shell
4.2.2 Creating the Session Global Object After Starting MySQL Shell
4.2.3 Scripting Sessions in JavaScript and Python Mode
4.3 MySQL Shell Connections
4.3.1 Connecting using Individual Parameters
4.3.2 Connecting using Unix Sockets and Windows Named Pipes
4.3.3 Using Encrypted Connections
4.3.4 Using Compressed Connections
4.4 Pluggable Password Store
4.4.1 Pluggable Password Configuration Options
4.4.2 Working with Credentials
4.5 MySQL Shell Global Objects
4.6 Using a Pager
5 MySQL Shell Code Execution
5.1 Active Language
5.2 Interactive Code Execution
5.3 Code Autocompletion
5.4 Editing Code
5.5 Code History
5.6 Batch Code Execution
5.7 Output Formats
5.7.1 Table Format
5.7.2 Tab Separated Format
5.7.3 Vertical Format
5.7.4 JSON Format Output
5.7.5 JSON Wrapping
5.7.6 Result Metadata
5.8 API Command Line Integration
5.8.1 Command Line Integration Overview
5.8.2 Command Line Integration Details
6 MySQL AdminAPI
6.1 Using MySQL AdminAPI
6.1.1 Installing the Components
6.1.2 Using Instances Running MySQL 5.7
6.1.3 Configuring the Host Name
6.1.4 Specifying Instances
6.1.5 Persisting Settings
6.1.6 Retrieving a Handler Object
6.1.7 Creating User Accounts for Administration
6.1.8 Verbose Logging
6.1.9 Finding the Primary
6.1.10 Scripting AdminAPI
6.2 AdminAPI MySQL Sandboxes
6.2.1 Deploying Sandbox Instances
6.2.2 Managing Sandbox Instances
6.3 Tagging Metadata
6.4 Using MySQL Router with AdminAPI, InnoDB Cluster, and InnoDB ReplicaSet
6.4.1 Bootstrapping MySQL Router
6.4.2 Configuring the MySQL Router User
6.4.3 Deploying MySQL Router
6.4.4 Using ReplicaSets with MySQL Router
6.4.5 Testing InnoDB Cluster High Availability
6.4.6 Working with a Cluster's Routers
7 MySQL InnoDB Cluster
7.1 MySQL InnoDB Cluster Requirements
7.2 Deploying a Production InnoDB Cluster
7.2.1 Deploying a New Production InnoDB Cluster
7.2.2 Using MySQL Clone with InnoDB Cluster
7.2.3 Adopting a Group Replication Deployment
7.3 Monitoring InnoDB Cluster
7.4 Working with Instances
7.5 Working with InnoDB Cluster
7.6 Configuring InnoDB Cluster
7.7 Troubleshooting InnoDB Cluster
7.8 Upgrading an InnoDB Cluster
7.8.1 Rolling Upgrades
7.8.2 Upgrading InnoDB Cluster Metadata
7.8.3 Troubleshooting InnoDB Cluster Upgrades
7.9 InnoDB Cluster Tips
7.10 InnoDB Cluster Limitations
8 MySQL InnoDB ReplicaSet
8.1 Deploying InnoDB ReplicaSet
8.2 Adding Instances to a ReplicaSet
8.3 Adopting an Existing Replication Set Up
8.4 Working with InnoDB ReplicaSet
9 Extending MySQL Shell
9.1 Reporting with MySQL Shell
9.1.1 Creating MySQL Shell Reports
9.1.2 Registering MySQL Shell Reports
9.1.3 Persisting MySQL Shell Reports
9.1.4 Example MySQL Shell Report
9.1.5 Running MySQL Shell Reports
9.1.6 Built-in MySQL Shell Reports
9.2 Adding Extension Objects to MySQL Shell
9.2.1 Creating User-Defined MySQL Shell Global Objects
9.2.2 Creating Extension Objects
9.2.3 Persisting Extension Objects
9.2.4 Example MySQL Shell Extension Objects
9.3 MySQL Shell Plugins
9.3.1 Creating MySQL Shell Plugins
9.3.2 Creating Plugin Groups
9.3.3 Example MySQL Shell Plugins
10 MySQL Shell Utilities
10.1 Upgrade Checker Utility
10.2 JSON Import Utility
10.2.1 Importing JSON documents with the mysqlsh command interface
10.2.2 Importing JSON documents with the --import command
10.2.3 Conversions for representations of BSON data types
10.3 Table Export Utility
10.4 Parallel Table Import Utility
10.5 Instance Dump Utility, Schema Dump Utility, and Table Dump Utility
10.6 Dump Loading Utility
11 MySQL Shell Logging and Debug
11.1 Application Log
11.2 Verbose Output
11.3 System Logging for SQL Statements
11.4 Logging AdminAPI Operations
12 Customizing MySQL Shell
12.1 Working With Startup Scripts
12.2 Adding Module Search Paths
12.2.1 Module Search Path Environment Variables
12.2.2 Module Search Path Variable in Startup Scripts
12.3 Customizing the Prompt
12.4 Configuring MySQL Shell Options
A MySQL Shell Command Reference
A.1 mysqlsh — The MySQL Shell