Create a user in MySQL instance

This sample demonstrates how to create a new user in a given Cloud SQL for MySQL instance.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample

Terraform

To learn how to apply or remove a Terraform configuration, see Basic Terraform commands. For more information, see the Terraform provider reference documentation.

resource "random_password" "pwd" {
  length  = 16
  special = false
}

resource "google_sql_user" "user" {
  name     = "user"
  instance = google_sql_database_instance.instance.name
  password = random_password.pwd.result
}

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.