MySQL Blog Archive
For the latest blogs go to
Take the new MySQL Shell for a Spin ... in Docker!

The most recent release of MySQL Server — 5.7.12 — ships with the X Plugin, which opens up an entirely new area of functionality: In addition to the classical relational approach to data management using SQL, MySQL can now also be used as a schemaless document store, something which is commonly referred to as a NoSQL database.

In order to support document store operations, we ship a new shell, currently in alpha, that introduces functions to query, update and manage MySQL as a document store, using popular scripting languages such as JavaScript and Python. It also covers the same areas of usage as the venerable mysql command line client, so you can also use it to perform classical, relational SQL operations on your database.

Get Going

With the shell currently in alpha, it is a bit early to base your production database management on it, but using Docker we have set up a very easy way for you to take it for a spin and get an idea not only of the capabilities of the shell itself, but also of the versatility and flexibility of the new document store. We won’t even assume that you have a MySQL Server instance around to play with. Here is how to do it:

Spin up a MySQL Server container. The following gives you a container named mysql-container, running the latest version of MySQL Server. Substitute the root user password you want, but please note that this is not a secure way to run MySQL in Docker and should not be used on production systems.

docker run --name mysql-container -e MYSQL_ROOT_PASSWORD=my-password -d mysql/mysql-server:latest

Start a MySQL Shell container and enable the X Plugin. Before you can start using MySQL as a document store, you will need to enable the server side plugin that provides this functionality. The following command line will start a Shell container, initiate a shell session against the MySQL server, enable the plugin, then stop and delete the shell container:

docker run -it --link mysql-container --rm -e MYSQL_HOST=mysql-container mysql/shell init

Spin up the shell and try it out! Finally, we start a normal shell user session against the MySQL container. Substitute the name of the user as appropriate; if you follow this guide to the letter, you should log in as root using the password you set on the command line when spinning up the MySQL server:

docker run -it --link mysql-container mysql/shell -u username -h mysql-container

More information on the MySQL Shell Docker image is available over on Docker Hub, including how to use it against a non-containerized MySQL instance, which is just a simple variation on the steps above.

Some Things to Try Out

Now that you have a MySQL Shell container up and running, one thing you might want to do is check out the tutorials in the MySQL 5.7 Reference Manual. There is one on using it with JavaScript and one for Python. And there is the MySQL Shell User’s Guide which provides in-depth information on the functionality currently available in the new MySQL Shell.

There is also a series of posts over on the MySQL Server Team Blog that you may want to look at. In particular these ones:

With that, here’s hoping that I have whetted your appetite a bit to go see what this new stuff is all about, and I hope we have given you an easy and straightforward way to do so. If you encounter issues or have suggestions for improvements or just want to comment, please either drop us a line here or file a bug in the MySQL bug database.