Updated on 2024-04-03 GMT+08:00

Creating a Database

Scenarios

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

If your RDS instance is associated with a DDM instance, go to the DDM console to manage databases and accounts.

Constraints

  • Databases cannot be created for DB instances that are in the process of being restored.
  • You can only manage databases in the primary instance, for example, creating or authorizing users for databases.
  • This section applies only to the MySQL DB engine.
  • Database names must be unique.
  • After a database is created, the database name cannot be changed.
  • Databases and accounts created using other methods than the RDS console and APIs are also displayed on the RDS console. If the names of the created databases or accounts do not meet the database naming rule or account naming rule, for example, the names containing Chinese characters or unsupported special characters, the databases or accounts cannot be managed on the RDS console or through APIs.
  • If the name of any database or account on the source database does not meet the database naming rule or account naming rule, the database or account cannot be managed on the RDS console or through APIs after being migrated to the destination RDS for MySQL instance.

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 in the upper left corner of the page and choose Databases > Relational Database Service.
  4. On the Instances page, click the target DB instance.
  5. On the Databases page, click Create Database. In the displayed dialog box, enter a database name and remarks, select a character set, and authorize permissions for users. Then, click OK.

    Figure 1 Creating a database

    • The database name consists of 1 to 64 characters. Only letters, digits, hyphens (-), underscores (_), and dollar signs ($) are allowed. RDS for MySQL 8.0 does not support dollar signs ($). The total number of hyphens (-) and dollar signs ($) cannot exceed 10.
    • The default character set is utf8. You can click More and select another one.
    • The remarks can be empty or contain up to 512 characters. This parameter is available only for specified kernel versions. If your kernel version does not meet the following requirements, upgrade the kernel to the latest version by referring to Upgrading a Minor Version.
      • For RDS for MySQL 5.6, the kernel version should be 5.6.51.3 or later.
      • For RDS for MySQL 5.7, the kernel version should be 5.7.33.1 or later.
      • For RDS for MySQL 8.0, the kernel version should be 8.0.21.4 or later.
    • Select unauthorized users and click to authorize permissions or select authorized users and click to revoke permissions.

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

    • If you require fine-grained permissions control, 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 in the upper left corner of the page and choose Databases > Relational Database Service.
  4. On the Instances page, locate the DB instance and click Log In in the Operation column.
  5. On the displayed login page, enter the correct username and password and click Log In.
  6. On the top menu bar, choose SQL Operations > SQL Query.
  7. Run the following command to create a database.

    create database database_name;