Create a new container with MySQL Shell to administer a MySQL InnoDB Cluster. This is the preferred method, although every MySQL Operator for Kubernetes and MySQL InnoDB Cluster container also has MySQL Shell installed if you need to troubleshoot a specific pod.
These examples assume the InnoDB Cluster is named 'mycluster' and using the 'default' namespace.
Create the new container with MySQL Shell; this example uses
the MySQL Operator for Kubernetes image but other images work too, such as
container-registry.oracle.com/mysql/community-server:8.0
.
This example creates a new container named "myshell" using a MySQL Operator image, and immediately executes MySQL Shell:
$> kubectl run --rm -it myshell --image=container-registry.oracle.com/mysql/community-operator -- mysqlsh
If you don't see a command prompt, try pressing enter.
MySQL JS >
Now connect to the InnoDB Cluster from within MySQL Shell's interface:
MySQL JS> \connect root@mycluster
Creating a session to 'root@mycluster'
Please provide the password for 'root@mycluster': ******
MySQL mycluster JS>
The root@mycluster
shorthand works as it
assumes port 3306 (MySQL Router redirects to 6446) and the
default
namespace.
Optionally pass in additional arguments to mysqlsh, for example:
$> kubectl run --rm -it myshell --image=container-registry.oracle.com/mysql/community-operator -- mysqlsh root@mycluster --sql
If you don't see a command prompt, try pressing enter.
******
MySQL mycluster SQL>
The "******" represents entering the MySQL user's password to
MySQL Shell as MySQL Shell
prompts for a password by default. The
root@mycluster
represents user root on host
mycluster, and assumes the
default namespace. Setting
"-sql initiates MySQL Shell into SQL mode.
Troubleshooting a Specific Container
Every MySQL Operator for Kubernetes and MySQL InnoDB Cluster container has MySQL Shell installed, so for troubleshooting you may need to connect to a specific pod in the cluster. For example, connecting to a pod named mycluster-0:
$> kubectl --namespace default exec -it mycluster-0 -- bash
Defaulted container "sidecar" out of: sidecar, mysql, initconf (init), initmysql (init)
bash-4.4#
bash-4.4# mysqlsh root@localhost
Please provide the password for 'root@localhost': ******
...