For AI agents: this documentation is indexed for you in llms.txt, and all of it in /llms.txt. Every page is also available as markdown: append .md to its address.

Create a database

Important

To create a database, your database user must have the CREATEOpens in a new tab permission. You can use one of the system users to do so or create a special user with such permissions. For more information about the database users, see the Create a database user guide.

After you deploy the MySQL cluster using the DBInstance Custom Resource, you can create logical databases on this cluster. The Cennso Database extension lets you provision a logical database either declaratively, with the DBSchema Custom Resource, or manually. Both methods are described below.

Provision a database using DBSchema CR

To create a database using the DBSchema Custom Resource, create a claim with the database name you want to create and apply it to the Management Cluster. For example:

yaml

You can apply the DBSchema Custom Resource to your Management Cluster using the following command:

bash

After you apply the DBSchema manifest, a Kubernetes Job is created on the Core Cluster specified by {CORE-CLUSTER-NAME}. This Job creates a new logical database named {DATABASE-NAME} in the {NAMESPACE-WITH-DATABASE-CLUSTER} namespace.

To create a database at the given database instance, the Job must be able to find the database cluster. The spec.dbInstanceName field is used for this purpose. Set it to the metadata.name of the DBInstance claim related to the target database cluster.

Note

For now, the Cennso Database extension only creates the logical database. It does not update or delete it. Deleting a DBSchema Custom Resource from your Management Cluster does not drop the provisioned database from MySQL.

You can control the behaviour and lifetime of the Kubernetes Job generated by this CR using the standard configuration options of the Kubernetes JobOpens in a new tab:

  • spec.backoffLimit
  • spec.ttlSecondsAfterFinished
  • spec.activeDeadlineSeconds

Use spec.characterSet to set the character setOpens in a new tab and spec.collate to set the collation for the new database. For more information about the supported character sets and collation, see the Cennso Database Schema document.

Provision a database manually

To create a database, execute the following steps:

  1. Find the primary MySQL instance. The primary MySQL instance Pod must have the mysql.percona.com/primary label set to true. You can find the Pod with the primary MySQL instance using the following command:

    bash
  2. Get a shell to the primary MySQL instance container using the following command:

    bash
  3. Connect to the primary MySQL instance using the following command:

    bash
  4. Create a database using the CREATE DATABASE SQL statement. For example, you can use the following SQL statement to create a database with the cennso_database name:

    sql

For more information, see the official MySQL documentationOpens in a new tab.