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, InnoDB ClusterSet, and InnoDB ReplicaSet.

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: 2024-11-12 (revision: 80238)

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 login-path and Options Files
4.3.3 Connecting using Unix Sockets and Windows Named Pipes
4.3.4 Using Encrypted Connections
4.3.5 Using LDAP and Kerberos Authentication
4.3.6 Using an SSH Tunnel
4.3.7 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
4.7 Cloud Service Configuration
4.7.1 Oracle Cloud Infrastructure Object Storage
4.7.2 S3-compatible Storage
4.7.3 Azure Blob Storage
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
5.9 JSON Integration
5.10 Limitations
6 MySQL AdminAPI
6.1 Using MySQL AdminAPI
6.2 Installing AdminAPI Software Components
6.2.1 Using Instances Running MySQL 5.7
6.2.2 Configuring the Host Name
6.2.3 Connecting to Server Instances
6.2.4 Persisting Settings
6.3 Retrieving a Handler Object
6.4 Creating User Accounts for AdminAPI
6.5 Verbose Logging
6.6 Finding the Primary
6.7 Scripting AdminAPI
6.8 AdminAPI MySQL Sandboxes
6.8.1 Deploying Sandbox Instances
6.8.2 Managing Sandbox Instances
6.8.3 Setting up InnoDB Cluster and MySQL Router
6.9 Tagging Metadata
6.10 Using MySQL Router with AdminAPI, InnoDB Cluster, and InnoDB ReplicaSet
6.10.1 Bootstrapping MySQL Router
6.10.2 Configuring the MySQL Router User
6.10.3 Deploying MySQL Router
6.10.4 Using ReplicaSets with MySQL Router
6.10.5 Testing InnoDB Cluster High Availability
6.10.6 Working with a Cluster's Routers
6.11 Upgrade Metadata Schema
6.12 Locking Mechanism for AdminAPI Operations
7 MySQL InnoDB Cluster
7.1 InnoDB Cluster Requirements
7.2 InnoDB Cluster Limitations
7.3 User Accounts for InnoDB Cluster
7.4 Deploying a Production InnoDB Cluster
7.4.1 Pre-Checking Instance Configuration for InnoDB Cluster Usage
7.4.2 Configuring Production Instances for InnoDB Cluster Usage
7.4.3 Creating an InnoDB Cluster
7.4.4 Adding Instances to an InnoDB Cluster
7.4.5 Configuring InnoDB Cluster Ports
7.4.6 Using MySQL Clone with InnoDB Cluster
7.4.7 Adopting a Group Replication Deployment
7.5 Configuring InnoDB Cluster
7.5.1 Setting Options for InnoDB Cluster
7.5.2 Customizing InnoDB Cluster Member Servers
7.5.3 Configuring the Election Process
7.5.4 Configuring Failover Consistency
7.5.5 Configuring Automatic Rejoin of Instances
7.5.6 Configuring the Parallel Replication Applier
7.5.7 InnoDB Cluster and Auto-increment
7.5.8 InnoDB Cluster and Binary Log Purging
7.5.9 Configuring the Group Replication Communication Stack
7.6 Securing InnoDB Cluster
7.7 Monitoring InnoDB Cluster
7.8 Restoring and Rebooting an InnoDB Cluster
7.8.1 Rejoining an Instance to a Cluster
7.8.2 Restoring a Cluster from Quorum Loss
7.8.3 Rebooting a Cluster from a Major Outage
7.8.4 Rescanning a Cluster
7.8.5 Fencing a Cluster
7.9 Modifying or Dissolving an InnoDB Cluster
7.10 Upgrade InnoDB Cluster
7.10.1 InnoDB Cluster Upgrade
7.10.2 Troubleshooting InnoDB Cluster Upgrades
8 MySQL InnoDB ClusterSet
8.1 InnoDB ClusterSet Requirements
8.2 InnoDB ClusterSet Limitations
8.3 User Accounts for InnoDB ClusterSet
8.4 Deploying InnoDB ClusterSet
8.5 Integrating MySQL Router With InnoDB ClusterSet
8.6 InnoDB ClusterSet Status and Topology
8.7 InnoDB ClusterSet Controlled Switchover
8.8 InnoDB ClusterSet Emergency Failover
8.9 InnoDB ClusterSet Repair and Rejoin
8.9.1 Fencing Clusters in an InnoDB ClusterSet
8.9.2 Inconsistent Transaction Sets (GTID Sets) in InnoDB ClusterSet Clusters
8.9.3 Repairing Member Servers and Clusters in an InnoDB ClusterSet
8.9.4 Removing a Cluster from an InnoDB ClusterSet
8.9.5 Rejoining a Cluster to an InnoDB ClusterSet
8.10 Upgrade InnoDB ClusterSet
9 MySQL InnoDB ReplicaSet
9.1 Deploying InnoDB ReplicaSet
9.2 Configuring InnoDB ReplicaSet Instances
9.3 Creating an InnoDB ReplicaSet
9.4 Adding Instances to a ReplicaSet
9.4.1 Provisioning Instances for InnoDB ReplicaSet
9.4.2 Example of Adding Instances to a ReplicaSet
9.5 Adopting an Existing Replication Setup
9.6 Changing the Primary Instance
9.7 Forcing a New Primary Instance
9.8 Tagging ReplicaSets
9.9 Checking the Status of InnoDB ReplicaSet
9.10 Upgrade InnoDB ReplicaSet
10 Extending MySQL Shell
10.1 Reporting with MySQL Shell
10.1.1 Creating MySQL Shell Reports
10.1.2 Registering MySQL Shell Reports
10.1.3 Persisting MySQL Shell Reports
10.1.4 Example MySQL Shell Report
10.1.5 Running MySQL Shell Reports
10.1.6 Built-in MySQL Shell Reports
10.2 Adding Extension Objects to MySQL Shell
10.2.1 Creating User-Defined MySQL Shell Global Objects
10.2.2 Creating Extension Objects
10.2.3 Persisting Extension Objects
10.2.4 Example MySQL Shell Extension Objects
10.3 MySQL Shell Plugins
10.3.1 Creating MySQL Shell Plugins
10.3.2 Creating Plugin Groups
10.3.3 Example MySQL Shell Plugins
11 MySQL Shell Utilities
11.1 Upgrade Checker Utility
11.2 JSON Import Utility
11.2.1 Running the Utility
11.2.2 Importing JSON Documents With the Mysqlsh Command Interface
11.2.3 Importing JSON Documents With the --import Command
11.2.4 Conversions for Representations of BSON Data Types
11.3 Table Export Utility
11.4 Parallel Table Import Utility
11.5 Instance Dump Utility, Schema Dump Utility, and Table Dump Utility
11.6 Dump Loading Utility
11.7 Diagnostics Utilities
11.7.1 collectDiagnostics Utility
11.7.2 collectHighLoadDiagnostics Utility
11.7.3 collectSlowQueryDiagnostics Utility
12 MySQL Shell Logging and Debug
12.1 Application Log
12.2 Verbose Output
12.3 System Logging for User SQL Statements
12.4 MySQL Shell SQL Logging
12.5 Logging AdminAPI Operations
13 Customizing MySQL Shell
13.1 Working With Startup Scripts
13.2 Adding Module Search Paths
13.2.1 Module Search Path Environment Variables
13.2.2 Module Search Path Variable in Startup Scripts
13.3 Customizing the Prompt
13.4 Configuring MySQL Shell Options
A MySQL Shell Command Reference
A.1 mysqlsh — The MySQL Shell