Manage databases on your ApsaraDB RDS for MySQL instance by using the console, SQL statements, or API operations.
Prerequisites
Before you begin:
-
An ApsaraDB RDS for MySQL instance is created. Create an ApsaraDB RDS for MySQL instance
Create a database
Use the ApsaraDB RDS console
-
Go to the Instances page. In the top navigation bar, select the region of your RDS instance, then click the instance ID.
-
In the left-side navigation pane, click Databases.
-
Click Create Database.
-
Configure the following parameters.
If the database name contains a hyphen (
-), the system encodes the hyphen as@002din the underlying folder name.Parameter Description Database Name The database name. Must be 2 to 64 characters, start with a letter, and end with a letter or digit. Can contain lowercase letters, digits, underscores (_), and hyphens (-). Must be unique within the instance. Supported Character Set The character set. utf8mb4is recommended for most applications because it supports all Unicode characters.Authorized By Optional. The standard account to authorize on this database. Leave blank to assign permissions later. Only standard accounts are listed. The privileged account has full permissions on all databases by default. Description Optional. A description to help identify the database. Up to 256 characters. -
Click OK.
Use SQL statements
Connect to your RDS instance first. Use a client or the CLI to connect to an ApsaraDB RDS for MySQL instance.
Run the following statement to create a database:
CREATE DATABASE mydb;
To specify a character set and collation:
CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
Delete a database
Deleting a database permanently removes all its data. This action cannot be undone.
Use the ApsaraDB RDS console
-
Go to the Instances page. In the top navigation bar, select the region of your RDS instance, then click the instance ID.
-
In the left-side navigation pane, click Databases.
-
Find the database that you want to delete, and click Delete in the Actions column.
-
In the confirmation dialog box, click OK.
Use SQL statements
Connect to the RDS instance, then run:
DROP DATABASE mydb;
Account types and privileges
ApsaraDB RDS for MySQL provides two account types:
-
Privileged account: Has full permissions on all databases. Does not require per-database authorization.
-
Standard account: Requires explicit authorization for each database. Grant permissions through the Authorized By field when creating a database, or modify permissions later on the Accounts page. Modify the permissions of a standard account on an ApsaraDB RDS for MySQL instance.
Limits
| Resource | Privileged account | Standard account |
|---|---|---|
| Maximum databases | No limit. File system limits may apply. | No limit. File system limits may apply. |
| Maximum tables | Less than 200,000 | Less than 200,000 |
Database names cannot be changed after creation. To use a different name, create a new database, migrate the data, and delete the old one.
FAQ
Why is my database missing from the Data Management (DMS) console?
Common causes:
-
Your account does not have permissions on that database. Go to the Accounts page of the RDS instance to modify account permissions.
-
DMS has not synced the database metadata. Hover over the RDS instance in DMS and click the sync icon next to the instance name. You can also use the empty database initialization feature to sync database schemas.
Why can't I create a database?
Only privileged accounts and authorized standard accounts can create databases. If you use a standard account, ask the privileged account owner to grant permissions.
API reference
| Operation | Description |
|---|---|
| CreateDatabase | Creates a database on an RDS instance. |
| DeleteDatabase | Deletes a database from an RDS instance. |