Running MySQL Shell 8.0 with Docker

In a previous blog, I discussed how to pull, install and run MySQL 8.0 with Docker.  I showed how to connect to the Docker daemon with MySQL.

Now I will show you how to connect to the same Docker instance using the MySQL Shell which is a tool to use Document Store and to create InnoDB Clusters.

Installing Docker, Starting MySQL, and Connecting using MySQL Shell

First, you grab Docker: https://docs.docker.com/install .

Then, you pull and run MySQL 8.0 (Linux) by running the following.  Note that I’m not using a password which is just for testing a fleeting MySQL Docker container:

$ docker run –name mysql8 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -d mysql/mysql-server

Unable to find image ‘mysql/mysql-server:latest’ locally

Pull complete

Run the following command in bold to get the status of your MySQL container. Look for the word ‘healthy’ to know that it is running:

$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES8534edee97f mysql/mysql-server “/entrypoint.sh mysq…” 11 minutes ago Up 11 minutes (healthy) 3306/

Now you login to your containerized server, connecting with MySQL Shell:

$ docker exec -it mysql8 mysqlsh -uroot –mysql -S/var/lib/mysql/mysql.sock

Creating a Classic session to ‘root@/var%2Flib%2Fmysql%2Fmysql.sock’

Please provide the password for ‘root@/var%2Flib%2Fmysql%2Fmysql.sock’:

Fetching schema names for autocompletion… Press ^C to stop.

Your MySQL connection id is 13

Server version: 8.0.12 MySQL Community Server – GPL

No default schema selected; type \use to set one.

MySQL  localhost  JS >

That’s it!  You are now ready to use the MySQL 8.0 Shell to set up your InnoDB Cluster.

To connect with the MySQL 8.0 Shell to use Document Store, connect to the mysqlx daemon:

$ docker exec -it mysql8 mysqlsh -uroot -S/var/run/mysqld/mysqlx.sock

 

For more information on MySQL 8.0 Shell, please check here: https://dev.mysql.com/doc/mysql-shell/8.0/en/  .

“The statements and opinions expressed here are my own and do not necessarily represent those of the Oracle Corporation.”

-Kathy Forte, Oracle MySQL Solutions Architect

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s