juju deploy mysql-k8s --channel edge
Show information
You will need Juju 2.9 to be able to run this command. Learn how to upgrade to Juju 2.9.
Channel Version Revision Published Base
latest/edge 2 2 12 Jul 2021



Kubernetes charm for MySQL Read more

Relevant links

Discuss this charm

Share your thoughts on this charm with the community on discourse.

Join the discussion

MySQL Operator for K8s



The MySQL operator provides an open-source relational database management system (RDBMS). This repository contains a Juju Charm for deploying MySQL on Kubernetes clusters.

Note: This MySQL charm does not currently implement clustering. Therefore, scaling up with juju scale-application will result in multiple units with the same users and passwords, but no data synchronization.


Create a Juju model for your operators, say "mysql-k8s"

$ juju add-model mysql-k8s

The MySQL Operator may be deployed using the Juju command line

$ juju deploy mysql-k8s

If required, you can remove the deployment completely:

$ juju destroy-model -y mysql-k8s --no-wait --force --destroy-storage

Note the --destroy-storage will delete any data stored by MySQL in its persistent store.


This charm implements the following optional configs:

  • mysql_root_password: If it is not specified, the charm will generate one.
  • mysql_user: Create a new user with superuser privileges. This is used in conjunction with mysql_password.
  • mysql_password: Set the password for the mysql_user user.
  • mysql_database: Set the name of the default database.

And you can use it, like this:

$  juju deploy mysql-k8s --config mysql_user=JohnDoe --config mysql_password=SuperSecretUserPassword --config mysql_database=default_database

As in this example we did not specify the mysql_root_password, the charm will generate one, and you can get it executing:

$ juju show-unit mysql-k8s/0

The password will be the value for the key mysql_root_password


This charm implements the following actions:

  • create-user
  • delete-user
  • set-user-password
  • create-database

These actions are defined in the actions.yaml file in which you can find the parameters each action supports.

For example if you want to create a new user in MySQL you can run:

$ juju run-action --wait mysql-k8s/0 create-user username=myuser password=SuperSecretPassword
  UnitId: mysql-k8s/0
  id: "16"
  - 2021-06-24 22:07:47 -0300 -03 Username myuser created
    username: myuser
  status: completed
    completed: 2021-06-25 01:07:47 +0000 UTC
    enqueued: 2021-06-25 01:07:43 +0000 UTC
    started: 2021-06-25 01:07:46 +0000 UTC

For more information about actions, please refer to Juju documentation.


This charm provides a mysql_datastore relation so you can integrate this charm with others charms that requires a MySQL database.

OCI Images

This charm by default uses the latest version of the ubuntu/mysql image.