Code for creating a new database in mysql console

To create a new database in the MySQL console, you can use the following command:

CREATE DATABASE database_name;

Replace database_name with the name you want to give your new database.

For example, to create a database named mydatabase, you would use the following command:

CREATE DATABASE mydatabase;

If you want to create a database with a specific character set and collation, you can use the following command:

CREATE DATABASE database_name CHARACTER SET charset_name COLLATE collation_name;

Replace database_name with the name you want to give your new database, charset_name with the character set you want to use (e.g. utf8 or latin1), and collation_name with the collation you want to use (e.g. utf8_general_ci or latin1_swedish_ci).

For example, to create a database named mydatabase with the utf8 character set and utf8_general_ci collation, you would use the following command:

CREATE DATABASE mydatabase CHARACTER SET utf8 COLLATE utf8_general_ci;

Once you have created the database, you can use the USE command to select it as the current database:

USE mydatabase;

This will allow you to create tables, insert data, and perform other operations within the new database.