This topic describes how to create a database in MySQL mode by using an SQL statement.
Prerequisites
You have the CREATE privilege. For information about how to view your privileges, see View user privileges. If you do not have the CREATE privilege, contact the administrator to obtain the privilege. For more information, see Grant direct privileges.
Procedure
Log in to a MySQL tenant of a cluster.
Use the
CREATE DATABASEstatement to create a database.Here are some examples:
Create a database named
test2and set its character set toUTF8.obclient> CREATE DATABASE test2 DEFAULT CHARACTER SET UTF8; Query OK, 1 row affectedCreate a database named
test3that supports read and write operations.obclient> CREATE DATABASE test3 READ WRITE; Query OK, 1 row affectedCreate a read-only database named
test4.obclient> CREATE DATABASE test4 READ ONLY; Query OK, 1 row affected
References
For more information about the syntax of the CREATE DATABASE statement, see CREATE DATABASE.