MySQL Create Database

How to Create Database in MySQL Server with example?. Here, we will use both MySQL command prompt and Workbench for MySQL Create Database

MySQL Database is a storage location where you can store the business data. Every Database uses tables to store the information in a normalizes way. So, we can easily Insert, Select, Update, and Delete the business data. The MySQL create database command is to create a new database.

MySQL Create Database example

Before we start to create MySQL new database, Let us see the list of available databases in MySQL Server. To get this information, you have to use the SHOW DATABASES command.


The below screenshot will show you the available databases.

MySQL Create Database 1

The basic syntax to create MySQL Database is:


For the demonstration purpose, we are going to create a new database in MySQL called First_Database. So, Replace the Database_Name with First_Database, as shown below


From the below screenshot, you can observe that the MySQL command executed successfully.

MySQL Create Database 2

Now, let me show you the databases available. And you can see the first_database on the list

MySQL Create Database 3

MySQL Create Database using Workbench

Before we start creating a database in Workbench, let me open the Workbench. From the below screenshot, you can see a list of the available database under the Schemas pane.

MySQL Create Database 4

MySQL Create Database using Query in Workbench

In this example, we create a new database called second_database.

CREATE DATABASE second_database;

Click on the Execute button to execute the create database command

MySQL Create Database 5

From the below screenshot, you can see the command executed successfully, and you can see the second_database under schemas

MySQL Create Database 6

Create Database using Wizard in Workbench

If you are unaware or not familiar with queries, use Workbench to create a new MySQL database. To do so, within the Menu, click on the Create a New Schema in the Connected Server button.

MySQL Create Database 7

Once you select the option, the following tab window will open. Please change the Name of the schema from new_schema to Third_Database

MySQL Create Database 8

You can use the Collation drop-down box to change the Server Default collation.

MySQL Create Database 9

Click the apply button to create a new schema or database.

TIP: We configured the MySQL to convert the schema names and table names to lowercase by default. Because we used the Third_Database as the schema, it is saying that it will convert the name to lowercase.

MySQL Create Database 10

Click Apply button

MySQL Create Database 11

Next, click the Finish button

MySQL Create Database 12

Now, you can see the third_database under the schemas.

MySQL Create Database 13

TIP: If you didn’t find the newly created database in Workbench, Please click on the refresh button beside the Schemas

How to Check MySQL Database name exists or not

Let us see what will happen when we create a MySQL new database with an existing name. From the below screenshot, you can see it is throwing an error saying: Can’t create database third_database. Database exists.

CREATE DATABASE third_database;
MySQL Create Database 14

NOTE: In an organization, we may or may not have the privileges to know the available databases. So, it is always advisable to check whether the database name already exists or not

If you have the privilege to see the available databases, then you can use the SHOW DATABASES command to see a list of databases. If not, use the below option.

The following statement will only execute the MySQL Create Database Statement if the third_database is not available in the system database

MySQL Create Database 16

Let me try a different database name in the Create Database command

MySQL Create Database 15