1. Packages
  2. Mysql Provider
  3. API Docs
  4. User
MySQL v3.2.9 published on Wednesday, Feb 12, 2025 by Pulumi

mysql.User

Explore with Pulumi AI

The mysql.User resource creates and manages a user on a MySQL server.

Examples

Basic Usage

import * as pulumi from "@pulumi/pulumi";
import * as mysql from "@pulumi/mysql";

const jdoe = new mysql.User("jdoe", {
    user: "jdoe",
    host: "example.com",
    plaintextPassword: "password",
});
Copy
import pulumi
import pulumi_mysql as mysql

jdoe = mysql.User("jdoe",
    user="jdoe",
    host="example.com",
    plaintext_password="password")
Copy
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.NewUser(ctx, "jdoe", &mysql.UserArgs{
			User:              pulumi.String("jdoe"),
			Host:              pulumi.String("example.com"),
			PlaintextPassword: pulumi.String("password"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using MySql = Pulumi.MySql;

return await Deployment.RunAsync(() => 
{
    var jdoe = new MySql.User("jdoe", new()
    {
        UserName = "jdoe",
        Host = "example.com",
        PlaintextPassword = "password",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.mysql.User;
import com.pulumi.mysql.UserArgs;
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 jdoe = new User("jdoe", UserArgs.builder()
            .user("jdoe")
            .host("example.com")
            .plaintextPassword("password")
            .build());

    }
}
Copy
resources:
  jdoe:
    type: mysql:User
    properties:
      user: jdoe
      host: example.com
      plaintextPassword: password
Copy

Example Usage with an Authentication Plugin

import * as pulumi from "@pulumi/pulumi";
import * as mysql from "@pulumi/mysql";

const nologin = new mysql.User("nologin", {
    user: "nologin",
    host: "example.com",
    authPlugin: "mysql_no_login",
});
Copy
import pulumi
import pulumi_mysql as mysql

nologin = mysql.User("nologin",
    user="nologin",
    host="example.com",
    auth_plugin="mysql_no_login")
Copy
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.NewUser(ctx, "nologin", &mysql.UserArgs{
			User:       pulumi.String("nologin"),
			Host:       pulumi.String("example.com"),
			AuthPlugin: pulumi.String("mysql_no_login"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using MySql = Pulumi.MySql;

return await Deployment.RunAsync(() => 
{
    var nologin = new MySql.User("nologin", new()
    {
        UserName = "nologin",
        Host = "example.com",
        AuthPlugin = "mysql_no_login",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.mysql.User;
import com.pulumi.mysql.UserArgs;
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 nologin = new User("nologin", UserArgs.builder()
            .user("nologin")
            .host("example.com")
            .authPlugin("mysql_no_login")
            .build());

    }
}
Copy
resources:
  nologin:
    type: mysql:User
    properties:
      user: nologin
      host: example.com
      authPlugin: mysql_no_login
Copy

Create User Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new User(name: string, args: UserArgs, opts?: CustomResourceOptions);
@overload
def User(resource_name: str,
         args: UserArgs,
         opts: Optional[ResourceOptions] = None)

@overload
def User(resource_name: str,
         opts: Optional[ResourceOptions] = None,
         user: Optional[str] = None,
         auth_plugin: Optional[str] = None,
         host: Optional[str] = None,
         password: Optional[str] = None,
         plaintext_password: Optional[str] = None,
         tls_option: Optional[str] = None)
func NewUser(ctx *Context, name string, args UserArgs, opts ...ResourceOption) (*User, error)
public User(string name, UserArgs args, CustomResourceOptions? opts = null)
public User(String name, UserArgs args)
public User(String name, UserArgs args, CustomResourceOptions options)
type: mysql:User
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. UserArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. UserArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. UserArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. UserArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. UserArgs
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 userResource = new MySql.User("userResource", new()
{
    UserName = "string",
    AuthPlugin = "string",
    Host = "string",
    PlaintextPassword = "string",
    TlsOption = "string",
});
Copy
example, err := mysql.NewUser(ctx, "userResource", &mysql.UserArgs{
	User:              pulumi.String("string"),
	AuthPlugin:        pulumi.String("string"),
	Host:              pulumi.String("string"),
	PlaintextPassword: pulumi.String("string"),
	TlsOption:         pulumi.String("string"),
})
Copy
var userResource = new User("userResource", UserArgs.builder()
    .user("string")
    .authPlugin("string")
    .host("string")
    .plaintextPassword("string")
    .tlsOption("string")
    .build());
Copy
user_resource = mysql.User("userResource",
    user="string",
    auth_plugin="string",
    host="string",
    plaintext_password="string",
    tls_option="string")
Copy
const userResource = new mysql.User("userResource", {
    user: "string",
    authPlugin: "string",
    host: "string",
    plaintextPassword: "string",
    tlsOption: "string",
});
Copy
type: mysql:User
properties:
    authPlugin: string
    host: string
    plaintextPassword: string
    tlsOption: string
    user: string
Copy

User Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The User resource accepts the following input properties:

UserName
This property is required.
Changes to this property will trigger replacement.
string
The name of the user.
AuthPlugin Changes to this property will trigger replacement. string
Use an [authentication plugin][ref-auth-plugins] to authenticate the user instead of using password authentication. Description of the fields allowed in the block below. Conflicts with password and plaintext_password.
Host Changes to this property will trigger replacement. string
The source host of the user. Defaults to "localhost".
Password string
Deprecated alias of plaintext_password, whose value is stored as plaintext in state. Prefer to use plaintext_password instead, which stores the password as an unsalted hash. Conflicts with auth_plugin.

Deprecated: Please use plaintext_password instead

PlaintextPassword string
The password for the user. This must be provided in plain text, so the data source for it must be secured. An unsalted hash of the provided password is stored in state. Conflicts with auth_plugin.
TlsOption Changes to this property will trigger replacement. string
An TLS-Option for the CREATE USER or ALTER USER statement. The value is suffixed to REQUIRE. A value of 'SSL' will generate a CREATE USER ... REQUIRE SSL statement. See the MYSQL CREATE USER documentation for more. Ignored if MySQL version is under 5.7.0.
User
This property is required.
Changes to this property will trigger replacement.
string
The name of the user.
AuthPlugin Changes to this property will trigger replacement. string
Use an [authentication plugin][ref-auth-plugins] to authenticate the user instead of using password authentication. Description of the fields allowed in the block below. Conflicts with password and plaintext_password.
Host Changes to this property will trigger replacement. string
The source host of the user. Defaults to "localhost".
Password string
Deprecated alias of plaintext_password, whose value is stored as plaintext in state. Prefer to use plaintext_password instead, which stores the password as an unsalted hash. Conflicts with auth_plugin.

Deprecated: Please use plaintext_password instead

PlaintextPassword string
The password for the user. This must be provided in plain text, so the data source for it must be secured. An unsalted hash of the provided password is stored in state. Conflicts with auth_plugin.
TlsOption Changes to this property will trigger replacement. string
An TLS-Option for the CREATE USER or ALTER USER statement. The value is suffixed to REQUIRE. A value of 'SSL' will generate a CREATE USER ... REQUIRE SSL statement. See the MYSQL CREATE USER documentation for more. Ignored if MySQL version is under 5.7.0.
user
This property is required.
Changes to this property will trigger replacement.
String
The name of the user.
authPlugin Changes to this property will trigger replacement. String
Use an [authentication plugin][ref-auth-plugins] to authenticate the user instead of using password authentication. Description of the fields allowed in the block below. Conflicts with password and plaintext_password.
host Changes to this property will trigger replacement. String
The source host of the user. Defaults to "localhost".
password String
Deprecated alias of plaintext_password, whose value is stored as plaintext in state. Prefer to use plaintext_password instead, which stores the password as an unsalted hash. Conflicts with auth_plugin.

Deprecated: Please use plaintext_password instead

plaintextPassword String
The password for the user. This must be provided in plain text, so the data source for it must be secured. An unsalted hash of the provided password is stored in state. Conflicts with auth_plugin.
tlsOption Changes to this property will trigger replacement. String
An TLS-Option for the CREATE USER or ALTER USER statement. The value is suffixed to REQUIRE. A value of 'SSL' will generate a CREATE USER ... REQUIRE SSL statement. See the MYSQL CREATE USER documentation for more. Ignored if MySQL version is under 5.7.0.
user
This property is required.
Changes to this property will trigger replacement.
string
The name of the user.
authPlugin Changes to this property will trigger replacement. string
Use an [authentication plugin][ref-auth-plugins] to authenticate the user instead of using password authentication. Description of the fields allowed in the block below. Conflicts with password and plaintext_password.
host Changes to this property will trigger replacement. string
The source host of the user. Defaults to "localhost".
password string
Deprecated alias of plaintext_password, whose value is stored as plaintext in state. Prefer to use plaintext_password instead, which stores the password as an unsalted hash. Conflicts with auth_plugin.

Deprecated: Please use plaintext_password instead

plaintextPassword string
The password for the user. This must be provided in plain text, so the data source for it must be secured. An unsalted hash of the provided password is stored in state. Conflicts with auth_plugin.
tlsOption Changes to this property will trigger replacement. string
An TLS-Option for the CREATE USER or ALTER USER statement. The value is suffixed to REQUIRE. A value of 'SSL' will generate a CREATE USER ... REQUIRE SSL statement. See the MYSQL CREATE USER documentation for more. Ignored if MySQL version is under 5.7.0.
user
This property is required.
Changes to this property will trigger replacement.
str
The name of the user.
auth_plugin Changes to this property will trigger replacement. str
Use an [authentication plugin][ref-auth-plugins] to authenticate the user instead of using password authentication. Description of the fields allowed in the block below. Conflicts with password and plaintext_password.
host Changes to this property will trigger replacement. str
The source host of the user. Defaults to "localhost".
password str
Deprecated alias of plaintext_password, whose value is stored as plaintext in state. Prefer to use plaintext_password instead, which stores the password as an unsalted hash. Conflicts with auth_plugin.

Deprecated: Please use plaintext_password instead

plaintext_password str
The password for the user. This must be provided in plain text, so the data source for it must be secured. An unsalted hash of the provided password is stored in state. Conflicts with auth_plugin.
tls_option Changes to this property will trigger replacement. str
An TLS-Option for the CREATE USER or ALTER USER statement. The value is suffixed to REQUIRE. A value of 'SSL' will generate a CREATE USER ... REQUIRE SSL statement. See the MYSQL CREATE USER documentation for more. Ignored if MySQL version is under 5.7.0.
user
This property is required.
Changes to this property will trigger replacement.
String
The name of the user.
authPlugin Changes to this property will trigger replacement. String
Use an [authentication plugin][ref-auth-plugins] to authenticate the user instead of using password authentication. Description of the fields allowed in the block below. Conflicts with password and plaintext_password.
host Changes to this property will trigger replacement. String
The source host of the user. Defaults to "localhost".
password String
Deprecated alias of plaintext_password, whose value is stored as plaintext in state. Prefer to use plaintext_password instead, which stores the password as an unsalted hash. Conflicts with auth_plugin.

Deprecated: Please use plaintext_password instead

plaintextPassword String
The password for the user. This must be provided in plain text, so the data source for it must be secured. An unsalted hash of the provided password is stored in state. Conflicts with auth_plugin.
tlsOption Changes to this property will trigger replacement. String
An TLS-Option for the CREATE USER or ALTER USER statement. The value is suffixed to REQUIRE. A value of 'SSL' will generate a CREATE USER ... REQUIRE SSL statement. See the MYSQL CREATE USER documentation for more. Ignored if MySQL version is under 5.7.0.

Outputs

All input properties are implicitly available as output properties. Additionally, the User 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 User Resource

Get an existing User 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?: UserState, opts?: CustomResourceOptions): User
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        auth_plugin: Optional[str] = None,
        host: Optional[str] = None,
        password: Optional[str] = None,
        plaintext_password: Optional[str] = None,
        tls_option: Optional[str] = None,
        user: Optional[str] = None) -> User
func GetUser(ctx *Context, name string, id IDInput, state *UserState, opts ...ResourceOption) (*User, error)
public static User Get(string name, Input<string> id, UserState? state, CustomResourceOptions? opts = null)
public static User get(String name, Output<String> id, UserState state, CustomResourceOptions options)
resources:  _:    type: mysql:User    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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.
The following state arguments are supported:
AuthPlugin Changes to this property will trigger replacement. string
Use an [authentication plugin][ref-auth-plugins] to authenticate the user instead of using password authentication. Description of the fields allowed in the block below. Conflicts with password and plaintext_password.
Host Changes to this property will trigger replacement. string
The source host of the user. Defaults to "localhost".
Password string
Deprecated alias of plaintext_password, whose value is stored as plaintext in state. Prefer to use plaintext_password instead, which stores the password as an unsalted hash. Conflicts with auth_plugin.

Deprecated: Please use plaintext_password instead

PlaintextPassword string
The password for the user. This must be provided in plain text, so the data source for it must be secured. An unsalted hash of the provided password is stored in state. Conflicts with auth_plugin.
TlsOption Changes to this property will trigger replacement. string
An TLS-Option for the CREATE USER or ALTER USER statement. The value is suffixed to REQUIRE. A value of 'SSL' will generate a CREATE USER ... REQUIRE SSL statement. See the MYSQL CREATE USER documentation for more. Ignored if MySQL version is under 5.7.0.
UserName Changes to this property will trigger replacement. string
The name of the user.
AuthPlugin Changes to this property will trigger replacement. string
Use an [authentication plugin][ref-auth-plugins] to authenticate the user instead of using password authentication. Description of the fields allowed in the block below. Conflicts with password and plaintext_password.
Host Changes to this property will trigger replacement. string
The source host of the user. Defaults to "localhost".
Password string
Deprecated alias of plaintext_password, whose value is stored as plaintext in state. Prefer to use plaintext_password instead, which stores the password as an unsalted hash. Conflicts with auth_plugin.

Deprecated: Please use plaintext_password instead

PlaintextPassword string
The password for the user. This must be provided in plain text, so the data source for it must be secured. An unsalted hash of the provided password is stored in state. Conflicts with auth_plugin.
TlsOption Changes to this property will trigger replacement. string
An TLS-Option for the CREATE USER or ALTER USER statement. The value is suffixed to REQUIRE. A value of 'SSL' will generate a CREATE USER ... REQUIRE SSL statement. See the MYSQL CREATE USER documentation for more. Ignored if MySQL version is under 5.7.0.
User Changes to this property will trigger replacement. string
The name of the user.
authPlugin Changes to this property will trigger replacement. String
Use an [authentication plugin][ref-auth-plugins] to authenticate the user instead of using password authentication. Description of the fields allowed in the block below. Conflicts with password and plaintext_password.
host Changes to this property will trigger replacement. String
The source host of the user. Defaults to "localhost".
password String
Deprecated alias of plaintext_password, whose value is stored as plaintext in state. Prefer to use plaintext_password instead, which stores the password as an unsalted hash. Conflicts with auth_plugin.

Deprecated: Please use plaintext_password instead

plaintextPassword String
The password for the user. This must be provided in plain text, so the data source for it must be secured. An unsalted hash of the provided password is stored in state. Conflicts with auth_plugin.
tlsOption Changes to this property will trigger replacement. String
An TLS-Option for the CREATE USER or ALTER USER statement. The value is suffixed to REQUIRE. A value of 'SSL' will generate a CREATE USER ... REQUIRE SSL statement. See the MYSQL CREATE USER documentation for more. Ignored if MySQL version is under 5.7.0.
user Changes to this property will trigger replacement. String
The name of the user.
authPlugin Changes to this property will trigger replacement. string
Use an [authentication plugin][ref-auth-plugins] to authenticate the user instead of using password authentication. Description of the fields allowed in the block below. Conflicts with password and plaintext_password.
host Changes to this property will trigger replacement. string
The source host of the user. Defaults to "localhost".
password string
Deprecated alias of plaintext_password, whose value is stored as plaintext in state. Prefer to use plaintext_password instead, which stores the password as an unsalted hash. Conflicts with auth_plugin.

Deprecated: Please use plaintext_password instead

plaintextPassword string
The password for the user. This must be provided in plain text, so the data source for it must be secured. An unsalted hash of the provided password is stored in state. Conflicts with auth_plugin.
tlsOption Changes to this property will trigger replacement. string
An TLS-Option for the CREATE USER or ALTER USER statement. The value is suffixed to REQUIRE. A value of 'SSL' will generate a CREATE USER ... REQUIRE SSL statement. See the MYSQL CREATE USER documentation for more. Ignored if MySQL version is under 5.7.0.
user Changes to this property will trigger replacement. string
The name of the user.
auth_plugin Changes to this property will trigger replacement. str
Use an [authentication plugin][ref-auth-plugins] to authenticate the user instead of using password authentication. Description of the fields allowed in the block below. Conflicts with password and plaintext_password.
host Changes to this property will trigger replacement. str
The source host of the user. Defaults to "localhost".
password str
Deprecated alias of plaintext_password, whose value is stored as plaintext in state. Prefer to use plaintext_password instead, which stores the password as an unsalted hash. Conflicts with auth_plugin.

Deprecated: Please use plaintext_password instead

plaintext_password str
The password for the user. This must be provided in plain text, so the data source for it must be secured. An unsalted hash of the provided password is stored in state. Conflicts with auth_plugin.
tls_option Changes to this property will trigger replacement. str
An TLS-Option for the CREATE USER or ALTER USER statement. The value is suffixed to REQUIRE. A value of 'SSL' will generate a CREATE USER ... REQUIRE SSL statement. See the MYSQL CREATE USER documentation for more. Ignored if MySQL version is under 5.7.0.
user Changes to this property will trigger replacement. str
The name of the user.
authPlugin Changes to this property will trigger replacement. String
Use an [authentication plugin][ref-auth-plugins] to authenticate the user instead of using password authentication. Description of the fields allowed in the block below. Conflicts with password and plaintext_password.
host Changes to this property will trigger replacement. String
The source host of the user. Defaults to "localhost".
password String
Deprecated alias of plaintext_password, whose value is stored as plaintext in state. Prefer to use plaintext_password instead, which stores the password as an unsalted hash. Conflicts with auth_plugin.

Deprecated: Please use plaintext_password instead

plaintextPassword String
The password for the user. This must be provided in plain text, so the data source for it must be secured. An unsalted hash of the provided password is stored in state. Conflicts with auth_plugin.
tlsOption Changes to this property will trigger replacement. String
An TLS-Option for the CREATE USER or ALTER USER statement. The value is suffixed to REQUIRE. A value of 'SSL' will generate a CREATE USER ... REQUIRE SSL statement. See the MYSQL CREATE USER documentation for more. Ignored if MySQL version is under 5.7.0.
user Changes to this property will trigger replacement. String
The name of the user.

Package Details

Repository
MySQL pulumi/pulumi-mysql
License
Apache-2.0
Notes
This Pulumi package is based on the mysql Terraform Provider.