41 lines
2.5 KiB
ReStructuredText

:original_name: ddm_06_0006.html
.. _ddm_06_0006:
Creating a Schema
=================
Prerequisites
-------------
- You have logged in to the DDM console.
- The DDM instance is in the **Running** state.
- Do not modify or delete the internal accounts (DDMRW*, DDMR*, and DDMREP*) created on data nodes. Otherwise, services will be affected.
.. note::
- The internal account name is in the format: Fixed prefix (such as DDMRW, DDMR, or DDMREP) + Hash value of the data node ID.
- A random password is generated, which contains 16 to 32 characters.
- All DB instances associated with one schema must have the same major MySQL version.
- Multiple schemas can be created in a DDM instance and associated with the same data node. One DDM instance can be associated with either RDS for MySQL or GaussDB(for MySQL) instances, but not both.
- One data node cannot be associated with schemas in different DDM instances.
- If you select **Sharded** for **Sharding** when you create a schema, the shard name follows the rule: schema+xxxx. *xxxx* indicates the digit increased from 0000. For example, if a schema name is **db_cbb5** and the total number of shards is 2, the shard names are **db_cbb5_0000** and **db_cbb5_0001**.
- Read-only DB instances cannot be associated with the schema as data nodes.
You can create a schema in two ways: on the **Instances** page or on the **Schemas** page. This section uses the **Instances** page as an example to describe how to create a schema.
Procedure
---------
#. In the navigation pane, choose **Instances**. In the instance list, locate the DDM instance that you want to create a schema for and click **Create Schema** in the **Operation** column.
#. On the displayed page, specify a sharding mode, enter a schema name, set the number of shards, select the required DDM accounts, and click **Next**.
#. Enter a database account with the required permissions and click **Test Connection**.
.. note::
Required permissions: SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER WITH GRANT OPTION
Create a special account and assign it the above permissions as required. Then use the account to create a schema for later operations.
#. After the test becomes successful, click **Finish**.