Creating a Database

This section applies only to the MySQL DB engine.

When using SQL statements to create a database, you are advised to log in as a user that you want to authorize and then create the database.

Database names must be unique.

After a database is created, the database name cannot be changed.

Scenarios

After a DB instance is created, you can create databases on it.

Constraints

Databases cannot be created for DB instances that are being restored.

Creating a Database through RDS

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and a project.
  3. Click Service List. Under Database, click Relational Database Service. The RDS console is displayed.
  4. On the Instance Management page, click the target DB instance.
  5. On the Databases page, click Create Database. In the displayed dialog box, enter a database name, select a character set, and authorize permissions for users. Then, click OK.

    Figure 1 Creating a database
    • The database name contains 1 to 64 characters. Only letters, digits, hyphens (-), underscores (_), and dollar signs ($) are allowed. The total number of hyphens (-) and dollar signs ($) cannot exceed 10. MySQL 8.0 does not support dollar signs ($).
    • The default character set is utf8. You can click Show and select another one.
    • Select unauthorized users and click to authorize permissions (mandatory) or select authorized users and click to revoke permissions.

      If there are no unauthorized users, you can create one by referring to section Creating a Database Account.

    • If you require fined-grained authorization, log in to the database through the DAS console.

  6. After the database is created, you can manage it on the Databases page of the selected DB instance.

    The AUTO_PK_ROW_ID column name is a reserved column name for the RDS for MySQL database and cannot be created by users.

Creating a Database through DAS

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and a project.
  3. Click Service List. Under Database, click Relational Database Service. The RDS console is displayed.
  4. On the Instance Management page, locate the target DB instance and click Log In in the Operation column.

    Figure 2 Logging in to a database

  5. On the displayed login page, enter the correct username and password and click Log In.
  6. In the SQL window, run the following command to create a database:

    create database Database name;