Chapter 2. Using MySQL Shell
2.0 Introduction
We discussed the mysql Client Program in Chapter 1. MySQL Shell is the modern alternative client. In addition to SQL, it supports nonrelational syntax for the database queries, also known as NoSQL, via the JavaScript or Python programming interface and provides a set of features to automate routine tasks.
In this chapter, we will discuss how to do the following:
Connect to MySQL Shell and select the right protocol
Select the SQL, JavaScript, or Python interface
Use both SQL and NoSQL syntax
Control the output format
Use MySQL Shell’s built-in utilities
Write a script to automate your custom needs
Use the Admin API
Reuse your scripts
Although MySQL Shell is a standard tool for certain tasks, it is not included in MySQL packages and needs to be installed separately. You can download it from the MySQL Shell download page or using the standard package manager of your operating system. We won’t cover MySQL Shell installation in this book, because it is straightforward.
The MySQL Shell’s command name is mysqlsh
. You can invoke it by typing mysqlsh
in the terminal.
MySQL Shell supports two protocols: the Classic MySQL protocol (similar to the one the mysql
client uses) and the new X protocol. The X protocol is a modern protocol that communicates with the MySQL server on a separate port (the default is 33060). It supports both SQL and NoSQL APIs and provides an asynchronous API, allowing clients to send multiple queries to the server without waiting ...
Get MySQL Cookbook, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.