Create and manage databases for MariaDB
Last updated on
Prerequisites
Section titled “Prerequisites”- You have a MariaDB instance.
Check Create and manage instances for MariaDB.
Preface
Section titled “Preface”This guide describes how you can add custom databases to your MariaDB instance. However, it is important to mention, that there is always a default database. It has the same name as the instances deployment name and it will exist regardless of that parameter value.
Create a database
Section titled “Create a database”-
Open your project in the STACKIT Portal.
-
Navigate to Databases > MariaDB.
-
Choose your instance and go to the overview.
-
In the Custom parameters panel, click on Edit.
-
Edit JSON input to define your new databases.
Add a new key-value-pair to the existing object where the key name is
databases. The value is an array of strings that defines all databases.Key Description Default Optional custom-database[n]-name The name of your desired custom databases This is the syntax of a key, that defines two additional databases.
"databases" : "[custom-database1-name]", "[custom-database2-name"]A complete definition of two additional databases named
db1anddb2could look like this example:{"max_disk_threshold": 80,"sgw_acl": "192.168.0.0/24,192.168.1.0","databases" : ["db1", "db2"]}
-
To use the Cloud Foundry CLI you first need to login into your STACKIT project endpoint. Read Interact with Cloud Foundry to get help logging in.
-
Create a database with the
cfcommand:Flag Description Default Optional service-name The instance identified by its service name for what you want to create the custom databases for custom-database[n]-name The name of your desired custom databases List services
Section titled “List services”Terminal window cf update-service [service-name] -c '{"databases" : ["[custom-database1-name]", "[custom-database1-name]"]}'This command results in the existence of the following databases:
default-database,db1,db2.
Delete a custom database
Section titled “Delete a custom database”-
Open your project in the STACKIT Portal.
-
Navigate to Databases > MariaDB.
-
Choose your instance and go to the overview.
-
In the Custom parameters panel, click on Edit.
-
Edit JSON input to define which databases should be dropped.
Do drop a database, you need to edit the
database-key. Because of its declarative character you need to omit the database, you want to drop, in the definition of databases. Refer to Create a database for the syntax of the key. To drop all custom databases, remove thedatabase-key entirely. Double check, that you don’t omit databases, that you want to keep.
-
To use the Cloud Foundry CLI you first need to login into your STACKIT project endpoint. Read Interact with Cloud Foundry to get help logging in.
-
Delete databases with the
cfcommand: You achieve the deletion of custom databases by omitting them in theupdate-servicecommand. Refer to Create a database on how to use the command. Double check, that you don’t omit databases, that you want to keep.If you want to drop all custom databases:
Flag Description Default Optional service-name The instance identified by its service name for what you want to delete all custom databases for Terminal window cf update-service [service-name] -c '{"databases" : []}'