Status
Done
Summary: in this tutorial, you will learn how to use the MySQL CREATE DATABASE statement to create a new database on a MySQL server.
Introduction to the MySQL CREATE DATABASE statement
To create a new database in MySQL, you use the CREATE DATABASE statement. The following illustrates the basic syntax of the CREATE DATABASE statement:
CREATE DATABASE [IF NOT EXISTS] database_name
[CHARACTER SET charset_name]
[COLLATE collation_name];In this syntax:
- First, specify the name of the database after the
CREATE DATABASEkeywords. The database name must be unique within a MySQL server instance. If you attempt to create a database with an existing name, MySQL will issue an error. - Second, use the
IF NOT EXISTSoption to create a database if it doesn’t exist conditionally. - Third, specify the character set and collation for the new database. If you skip the
CHARACTER SETandCOLLATEclauses, MySQL will use the default character set and collation for the new database.
‣