mysql.Database
Explore with Pulumi AI
The mysql.Database
resource creates and manages a database on a MySQL
server.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as mysql from "@pulumi/mysql";
const app = new mysql.Database("app", {name: "my_awesome_app"});
import pulumi
import pulumi_mysql as mysql
app = mysql.Database("app", name="my_awesome_app")
package main
import (
"github.com/pulumi/pulumi-mysql/sdk/v3/go/mysql"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := mysql.NewDatabase(ctx, "app", &mysql.DatabaseArgs{
Name: pulumi.String("my_awesome_app"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using MySql = Pulumi.MySql;
return await Deployment.RunAsync(() =>
{
var app = new MySql.Database("app", new()
{
Name = "my_awesome_app",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.mysql.Database;
import com.pulumi.mysql.DatabaseArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var app = new Database("app", DatabaseArgs.builder()
.name("my_awesome_app")
.build());
}
}
resources:
app:
type: mysql:Database
properties:
name: my_awesome_app
Create Database Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Database(name: string, args?: DatabaseArgs, opts?: CustomResourceOptions);
@overload
def Database(resource_name: str,
args: Optional[DatabaseArgs] = None,
opts: Optional[ResourceOptions] = None)
@overload
def Database(resource_name: str,
opts: Optional[ResourceOptions] = None,
default_character_set: Optional[str] = None,
default_collation: Optional[str] = None,
name: Optional[str] = None)
func NewDatabase(ctx *Context, name string, args *DatabaseArgs, opts ...ResourceOption) (*Database, error)
public Database(string name, DatabaseArgs? args = null, CustomResourceOptions? opts = null)
public Database(String name, DatabaseArgs args)
public Database(String name, DatabaseArgs args, CustomResourceOptions options)
type: mysql:Database
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args DatabaseArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args DatabaseArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args DatabaseArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args DatabaseArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args DatabaseArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var databaseResource = new MySql.Database("databaseResource", new()
{
DefaultCharacterSet = "string",
DefaultCollation = "string",
Name = "string",
});
example, err := mysql.NewDatabase(ctx, "databaseResource", &mysql.DatabaseArgs{
DefaultCharacterSet: pulumi.String("string"),
DefaultCollation: pulumi.String("string"),
Name: pulumi.String("string"),
})
var databaseResource = new Database("databaseResource", DatabaseArgs.builder()
.defaultCharacterSet("string")
.defaultCollation("string")
.name("string")
.build());
database_resource = mysql.Database("databaseResource",
default_character_set="string",
default_collation="string",
name="string")
const databaseResource = new mysql.Database("databaseResource", {
defaultCharacterSet: "string",
defaultCollation: "string",
name: "string",
});
type: mysql:Database
properties:
defaultCharacterSet: string
defaultCollation: string
name: string
Database Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The Database resource accepts the following input properties:
- Default
Character stringSet - The default character set to use when a table is created without specifying an explicit character set. Defaults to "utf8".
- Default
Collation string The default collation to use when a table is created without specifying an explicit collation. Defaults to
utf8_general_ci
. Each character set has its own set of collations, so changing the character set requires also changing the collation.Note that the defaults for character set and collation above do not respect any defaults set on the MySQL server, so that the configuration can be set appropriately even though this provider cannot see the server-level defaults. If you wish to use the server's defaults you must consult the server's configuration and then set the
default_character_set
anddefault_collation
to match.- Name string
- The name of the database. This must be unique within a given MySQL server and may or may not be case-sensitive depending on the operating system on which the MySQL server is running.
- Default
Character stringSet - The default character set to use when a table is created without specifying an explicit character set. Defaults to "utf8".
- Default
Collation string The default collation to use when a table is created without specifying an explicit collation. Defaults to
utf8_general_ci
. Each character set has its own set of collations, so changing the character set requires also changing the collation.Note that the defaults for character set and collation above do not respect any defaults set on the MySQL server, so that the configuration can be set appropriately even though this provider cannot see the server-level defaults. If you wish to use the server's defaults you must consult the server's configuration and then set the
default_character_set
anddefault_collation
to match.- Name string
- The name of the database. This must be unique within a given MySQL server and may or may not be case-sensitive depending on the operating system on which the MySQL server is running.
- default
Character StringSet - The default character set to use when a table is created without specifying an explicit character set. Defaults to "utf8".
- default
Collation String The default collation to use when a table is created without specifying an explicit collation. Defaults to
utf8_general_ci
. Each character set has its own set of collations, so changing the character set requires also changing the collation.Note that the defaults for character set and collation above do not respect any defaults set on the MySQL server, so that the configuration can be set appropriately even though this provider cannot see the server-level defaults. If you wish to use the server's defaults you must consult the server's configuration and then set the
default_character_set
anddefault_collation
to match.- name String
- The name of the database. This must be unique within a given MySQL server and may or may not be case-sensitive depending on the operating system on which the MySQL server is running.
- default
Character stringSet - The default character set to use when a table is created without specifying an explicit character set. Defaults to "utf8".
- default
Collation string The default collation to use when a table is created without specifying an explicit collation. Defaults to
utf8_general_ci
. Each character set has its own set of collations, so changing the character set requires also changing the collation.Note that the defaults for character set and collation above do not respect any defaults set on the MySQL server, so that the configuration can be set appropriately even though this provider cannot see the server-level defaults. If you wish to use the server's defaults you must consult the server's configuration and then set the
default_character_set
anddefault_collation
to match.- name string
- The name of the database. This must be unique within a given MySQL server and may or may not be case-sensitive depending on the operating system on which the MySQL server is running.
- default_
character_ strset - The default character set to use when a table is created without specifying an explicit character set. Defaults to "utf8".
- default_
collation str The default collation to use when a table is created without specifying an explicit collation. Defaults to
utf8_general_ci
. Each character set has its own set of collations, so changing the character set requires also changing the collation.Note that the defaults for character set and collation above do not respect any defaults set on the MySQL server, so that the configuration can be set appropriately even though this provider cannot see the server-level defaults. If you wish to use the server's defaults you must consult the server's configuration and then set the
default_character_set
anddefault_collation
to match.- name str
- The name of the database. This must be unique within a given MySQL server and may or may not be case-sensitive depending on the operating system on which the MySQL server is running.
- default
Character StringSet - The default character set to use when a table is created without specifying an explicit character set. Defaults to "utf8".
- default
Collation String The default collation to use when a table is created without specifying an explicit collation. Defaults to
utf8_general_ci
. Each character set has its own set of collations, so changing the character set requires also changing the collation.Note that the defaults for character set and collation above do not respect any defaults set on the MySQL server, so that the configuration can be set appropriately even though this provider cannot see the server-level defaults. If you wish to use the server's defaults you must consult the server's configuration and then set the
default_character_set
anddefault_collation
to match.- name String
- The name of the database. This must be unique within a given MySQL server and may or may not be case-sensitive depending on the operating system on which the MySQL server is running.
Outputs
All input properties are implicitly available as output properties. Additionally, the Database resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing Database Resource
Get an existing Database resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: DatabaseState, opts?: CustomResourceOptions): Database
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
default_character_set: Optional[str] = None,
default_collation: Optional[str] = None,
name: Optional[str] = None) -> Database
func GetDatabase(ctx *Context, name string, id IDInput, state *DatabaseState, opts ...ResourceOption) (*Database, error)
public static Database Get(string name, Input<string> id, DatabaseState? state, CustomResourceOptions? opts = null)
public static Database get(String name, Output<String> id, DatabaseState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Default
Character stringSet - The default character set to use when a table is created without specifying an explicit character set. Defaults to "utf8".
- Default
Collation string The default collation to use when a table is created without specifying an explicit collation. Defaults to
utf8_general_ci
. Each character set has its own set of collations, so changing the character set requires also changing the collation.Note that the defaults for character set and collation above do not respect any defaults set on the MySQL server, so that the configuration can be set appropriately even though this provider cannot see the server-level defaults. If you wish to use the server's defaults you must consult the server's configuration and then set the
default_character_set
anddefault_collation
to match.- Name string
- The name of the database. This must be unique within a given MySQL server and may or may not be case-sensitive depending on the operating system on which the MySQL server is running.
- Default
Character stringSet - The default character set to use when a table is created without specifying an explicit character set. Defaults to "utf8".
- Default
Collation string The default collation to use when a table is created without specifying an explicit collation. Defaults to
utf8_general_ci
. Each character set has its own set of collations, so changing the character set requires also changing the collation.Note that the defaults for character set and collation above do not respect any defaults set on the MySQL server, so that the configuration can be set appropriately even though this provider cannot see the server-level defaults. If you wish to use the server's defaults you must consult the server's configuration and then set the
default_character_set
anddefault_collation
to match.- Name string
- The name of the database. This must be unique within a given MySQL server and may or may not be case-sensitive depending on the operating system on which the MySQL server is running.
- default
Character StringSet - The default character set to use when a table is created without specifying an explicit character set. Defaults to "utf8".
- default
Collation String The default collation to use when a table is created without specifying an explicit collation. Defaults to
utf8_general_ci
. Each character set has its own set of collations, so changing the character set requires also changing the collation.Note that the defaults for character set and collation above do not respect any defaults set on the MySQL server, so that the configuration can be set appropriately even though this provider cannot see the server-level defaults. If you wish to use the server's defaults you must consult the server's configuration and then set the
default_character_set
anddefault_collation
to match.- name String
- The name of the database. This must be unique within a given MySQL server and may or may not be case-sensitive depending on the operating system on which the MySQL server is running.
- default
Character stringSet - The default character set to use when a table is created without specifying an explicit character set. Defaults to "utf8".
- default
Collation string The default collation to use when a table is created without specifying an explicit collation. Defaults to
utf8_general_ci
. Each character set has its own set of collations, so changing the character set requires also changing the collation.Note that the defaults for character set and collation above do not respect any defaults set on the MySQL server, so that the configuration can be set appropriately even though this provider cannot see the server-level defaults. If you wish to use the server's defaults you must consult the server's configuration and then set the
default_character_set
anddefault_collation
to match.- name string
- The name of the database. This must be unique within a given MySQL server and may or may not be case-sensitive depending on the operating system on which the MySQL server is running.
- default_
character_ strset - The default character set to use when a table is created without specifying an explicit character set. Defaults to "utf8".
- default_
collation str The default collation to use when a table is created without specifying an explicit collation. Defaults to
utf8_general_ci
. Each character set has its own set of collations, so changing the character set requires also changing the collation.Note that the defaults for character set and collation above do not respect any defaults set on the MySQL server, so that the configuration can be set appropriately even though this provider cannot see the server-level defaults. If you wish to use the server's defaults you must consult the server's configuration and then set the
default_character_set
anddefault_collation
to match.- name str
- The name of the database. This must be unique within a given MySQL server and may or may not be case-sensitive depending on the operating system on which the MySQL server is running.
- default
Character StringSet - The default character set to use when a table is created without specifying an explicit character set. Defaults to "utf8".
- default
Collation String The default collation to use when a table is created without specifying an explicit collation. Defaults to
utf8_general_ci
. Each character set has its own set of collations, so changing the character set requires also changing the collation.Note that the defaults for character set and collation above do not respect any defaults set on the MySQL server, so that the configuration can be set appropriately even though this provider cannot see the server-level defaults. If you wish to use the server's defaults you must consult the server's configuration and then set the
default_character_set
anddefault_collation
to match.- name String
- The name of the database. This must be unique within a given MySQL server and may or may not be case-sensitive depending on the operating system on which the MySQL server is running.
Import
Databases can be imported using their name, e.g.
$ pulumi import mysql:index/database:Database example my-example-database
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- MySQL pulumi/pulumi-mysql
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
mysql
Terraform Provider.