To create a new database in MySQL, you can use the CREATE DATABASE
statement. This statement allows you to specify the name of the database and other optional parameters such as the character set and collation.
Here is an example of how to create a new database named mydb
:
CREATE DATABASE mydb;
You can also specify the character set and collation for the database, as shown in the following example:
CREATE DATABASE mydb
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
Once the database has been created, you can use the USE
statement to switch to the new database and start creating tables and inserting data. For example:
USE mydb;
For more information and examples of how to create a new database in MySQL, please refer to the MySQL documentation.