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

Creating a Database

Scenarios

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

Constraints

  • Databases cannot be created for DB instances that are in the process of being restored.
  • Database names must be unique.
  • After a database is created, the database name cannot be changed.

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, select a character set, and authorize permissions for users. Then, click OK.

    Figure 1 Creating a database
    • The database name can contain 1 to 64 characters. Only letters, digits, hyphens (-), and underscores (_) are allowed. The total number of hyphens (-) cannot exceed 10.
    • The default character set is utf8. You can click More and select another one.
    • 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.

  6. After the database is created, manage it on the Databases page.

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 instance you want to log in and click Log In in the Operation column.
  5. On the displayed login page, enter the 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;

  8. Run the following command to view the database:

    show databases;