This topic describes how to create a database in the MySQL mode of OceanBase Database by using an SQL statement.
Prerequisites
You have the CREATE privilege. For information about how to view the privileges of the current user, see View user privileges. If you do not have the CREATE privilege, contact the administrator. For more information about how to grant privileges to a user, see Modify user privileges.
Procedure
Log on to a MySQL tenant of the cluster.
Use the
CREATE DATABASEstatement to create a database.Here are some examples:
Create a database named
test2and specify the character set asUTF8.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.