This topic describes how to create a database in an AnalyticDB for MySQL cluster by executing the CREATE DATABASE statement after you connect to the cluster. You can connect to the cluster by using Data Management Service (DMS), a MySQL client such as Navicat for MySQL, DBeaver, DbVisualizer, and SQL Workbench/J, application code, or the MySQL command line tool.

Background information

In the following example, DMS is used to create a database.

Note You can create up to 256 databases in each AnalyticDB for MySQL cluster.

Procedure

  1. Log on to the AnalyticDB for MySQL console.
  2. In the upper-left corner of the page, select the region where the target cluster resides.
  3. In the left-side navigation pane, click Clusters.
  4. On the V3.0 Clusters tab, click the target Cluster ID.
  5. In the upper-right corner of the Cluster Information page, click Log On to Database.
  6. Enter the information required to log on to the AnalyticDB for MySQL cluster.
    Log on to the cluster
    • 1. Enter the VPC endpoint and VPC port of the cluster in the <VPC endpoint>:<VPC port number> format. You can view the connection information on the Cluster Information page.
    • 2. Enter a database account of the cluster.
    • 3. Enter the password of the database account.
  7. Click Log On.
    Note If you want the web browser to remember the password, select Remember Password before you click Log On.
  8. In the top navigation bar of the DMS for AnalyticDB page, choose SQL Operations > SQL Window or SQL Operations > Command Window, and enter the CREATE DATABASE statement.
    dms
    • Syntax: CREATE DATABASE [IF NOT EXISTS] db_name
    • Example:
      create database adb_demo;                          
      create database if not exists adb_demo2;                         
  9. Click execute(F8) to create the database.
    Create a database