Interfaces and endpoints

Charmed MySQL supports modern mysql_client and legacy mysql, mysql-shared, mysql-router interfaces (in a backward compatible mode).

Interface

Endpoints

VM charm

K8s charm

modern

mysql_client

database

check

check

legacy

mysql

mysql

check

check

mysql_root

check

legacy

mysql-router

db-router

check

legacy

mysql-shared

shared-db

check

Caution

Do not relate both modern and legacy interfaces simultaneously.

Modern relations

This charm provides the modern mysql_clientinterface. Applications can easily connect MySQL using data_interfaces library from data-platform-libs.

mysql_client interface, database endpoint

Adding a Juju relation is accomplished with juju relate via endpoint database.

Example:

# Deploy Charmed MySQL cluster with 3 nodes
juju deploy mysql -n 3 --channel 8.0

# Deploy the relevant charms, e.g. mysql-test-app
juju deploy mysql-test-app

# Relate MySQL with your application
juju relate mysql:database mysql-test-app:database

# Check established relation (using mysql_client interface):
juju status --relations

# Example of the properly established relation:
# > Relation provider   Requirer                 Interface     Type
# > mysql:database      mysql-test-app:database  mysql_client  regular
# Deploy Charmed MySQL cluster with 3 nodes
juju deploy mysql-k8s -n 3 --trust --channel 8.0

# Deploy the relevant charms, e.g. mysql-test-app
juju deploy mysql-test-app

# Relate MySQL with your application
juju relate mysql-k8s:database mysql-test-app:database

# Check established relation (using mysql_client interface):
juju status --relations

# Example of the properly established relation:
# > Relation provider      Requirer                 Interface     Type
# > mysql-k8s:database     mysql-test-app:database  mysql_client  regular

See details about database user roles in Users.

Note

In order to integrate with this charm, every table created by the integrated application must have a primary key. This is required by the group replication plugin enabled in this charm.

Legacy relations

Legacy relations are deprecated and will be discontinued from Charmed MySQL 8.4 onward. Their usage should be avoided.

Check the legacy interface implementation limitations in Legacy charm.

This charm supports several legacy interfaces, e.g. mysql, mysql-shared, mysql-router. They were used in some legacy charms in cross-model relations.

mysql interface, mysql endpoint

This was a popular interface used by some legacy charms on both VM and K8s (e.g. MariaDB, OSM MariaDB, Percona Cluster and MySQL Innodb Cluster), often in cross-model relations.

Example usage of this interface:

juju deploy mysql --channel 8.0
juju config mysql mysql-interface-database=mediawiki mysql-interface-user=mediawiki
juju deploy mediawiki
juju relate mysql:mysql mediawiki:db
juju deploy mysql-k8s --trust --channel 8.0
juju config mysql-k8s mysql-interface-database=wordpress mysql-interface-user=wordpress
juju deploy wordpress-k8s
juju relate mysql-k8s:mysql wordpress-k8s:db

mysql_root endpoint (K8s only)

The K8s charm additionally supports the endpoint mysql_root, which provides the same legacy interface mysql with MySQL root-level privileges.

Caution

Usage of mysql_root is not recommended from security point of view.

mysql-router interface, db-router endpoint (VM only)

It is a relation that one uses with the mysql router charm.

As an example, the following commands can be executed to deploy and integrate Charmed MySQL VM to the keystone charm:

juju deploy mysql --channel 8.0
juju deploy mysql-router --series focal
juju deploy keystone --series focal
juju relate mysql-router keystone
juju relate mysql:db-router mysql-router:db-router

Note

Make sure to deploy identical series/base for keystone and mysql-router applications.

This is necessary due to the subordinate charm nature of mysql-router.

mysql-shared interface, shared-db endpoint (VM only)

It is a relation that one uses when the application needs to connect directly to the database cluster. It is supported by various legacy charms, e.g. mysql-innodb-cluster.

As an example, the following commands can be executed to deploy and integrate Charmed MySQL VM to the keystone charm:

juju deploy mysql --channel 8.0
juju deploy keystone --series focal
juju relate keystone:shared-db mysql:shared-db