Zum Hauptinhalt springen

Create a MySQL database with a MySQL user

POST/v2/projects/{projectId}/mysql-databases
API-Version
v2
Request-Methode
POST
Operation-ID
database-create-mysql-database

This operation creates a MySQL database and an associated MySQL user.

Request​

  • projectIdstringrequired

    ID of the Project to create a MySQLDatabase for.

Responses​

Format
application/json
Beschreibung

Created

  • idstring (uuid)required
  • userIdstring (uuid)required
Content-Type: application/json

{
"id": "f0f86186-0a5a-45b2-aa33-502777496347",
"userId": "f0f86186-0a5a-45b2-aa33-502777496347"
}
{
"properties": {
"id": {
"format": "uuid",
"type": "string"
},
"userId": {
"format": "uuid",
"type": "string"
}
},
"required": [
"id",
"userId"
],
"type": "object"
}

Nutzungsbeispiele​

$ curl \
--fail \
--location \
-X POST \
-d '{"database":{"characterSettings":{"characterSet":"utf8mb4","collation":"utf8mb4_general_ci"},"description":"string","version":"8.4"},"user":{"accessLevel":"full","description":"string","externalAccess":true,"password":"string"}}' \
-H "Authorization: Bearer $MITTWALD_API_TOKEN" \
-H 'Content-Type: application/json' \
https://api.mittwald.de/v2/projects/string/mysql-databases
import { MittwaldAPIV2Client } from "@mittwald/api-client";
import { assertStatus } from "@mittwald/api-client-commons";

const client = MittwaldAPIClient.newWithToken(process.env.MITTWALD_API_TOKEN);
const response = await client.database.createMysqlDatabase({
"projectId": "string",
"data": {
"database": {
"characterSettings": {
"characterSet": "utf8mb4",
"collation": "utf8mb4_general_ci"
},
"description": "string",
"version": "8.4"
},
"user": {
"accessLevel": "full",
"description": "string",
"externalAccess": true,
"password": "string"
}
}
});

assertStatus(response, 201);

use \Mittwald\ApiClient\Generated\V2\Clients\Database\CreateMysqlDatabase\CreateMysqlDatabaseRequest;
use \Mittwald\ApiClient\Generated\V2\Clients\Database\CreateMysqlDatabase\CreateMysqlDatabaseRequestBody;

$client = MittwaldAPIClient::newWithToken(getenv('MITTWALD_API_TOKEN'));

// TODO: Please consult the properties and constructor signature of
// CreateMysqlDatabaseRequestBody to learn how to construct a valid instance
$body = new CreateMysqlDatabaseRequestBody(/* TODO: ... */);

$request = (new CreateMysqlDatabaseRequest(
projectId: "string",
body: $body
));
$response = $client->database()->createMysqlDatabase($request);

var_dump($response->getBody();

Auf dieser Seite