MySQL CRETAE DATABASE Statement

Last Updated : 14 Mar, 2026

The MySQL CREATE DATABASE statement is used to create a new database where data can be stored and managed. It also supports optional settings like character set and collation to control how text data is stored and compared.

  • MySQL Command Line Client: Create a database by executing the CREATE DATABASE SQL statement directly in the command-line interface.
  • MySQL Workbench Application: Use the graphical interface of MySQL Workbench to create and manage databases visually.

MySQL Command Line Client

The MySQL Command Line Client allows you to create a database using the CREATE DATABASE statement. By entering SQL commands directly, users can efficiently manage databases, tables, and data, making it a powerful tool for database administration.

Syntax:

CREATE DATABASE [IF NOT EXISTS] database_name
[CHARACTER SET charset_name]
[COLLATE collation_name];
  • database_name: Name of the database to be created.
  • IF NOT EXISTS: Optional clause that prevents an error if a database with the same name already exists.
  • charset_name: Optional, defines the character set used to store text.
  • collation_name: Optional, specifies how character data is compared and sorted.

Implementation

The MySQL Command Line Client is installed by default when you install MySQL on your system. It allows users to interact directly with the MySQL database server using commands.

  • Provides a text-based environment where users can execute SQL queries directly.
  • Allows users to create, manage, and manipulate databases through SQL commands.

To create a database through the MYSQL command line client follows the below steps:

Step 1: Open MySQL Command Line Client

Search for MySQL Command Line Client from the Start menu and open the application.

Method1_CommandLineClient_Step1

Step 2: Enter Password

After opening the client, enter the MySQL root password that was set during installation.

Method1_CommandLineClient_Step2

Step 3: View Existing Databases

Run the following command to see all databases currently available in the system.

SHOW DATABASES;

Output:

Method1_CommandLineClient_Step3
All databases present in the system

Step 4: Create a New Database

Execute the following command to create a new database.

CREATE DATABASE IF NOT EXISTS DATABASE_NAME;

Output:

Method1_CommandLineClient_Step4

If the command runs successfully, the database will be created.

Step 5: Verify Database Creation

Run the following command again to confirm the database has been created.

SHOW DATABASES;

Output:

Method1_CommandLineClient_Step5

Step 6: Use the Database

To start working with the database, run the following command:

USE DATABASE_NAME;

MySQL Workbench

MySQL Workbench is a graphical tool used to design, manage, and interact with MySQL databases. It provides a Graphical User Interface (GUI) that simplifies database management compared to command-line operations.

  • Allows users to visually create and manage databases, tables, and queries.
  • Suitable for users who prefer a graphical interface instead of working with command-line tools.

Implementation

MySQL Workbench is a graphical tool used to design, manage, and interact with MySQL databases. You can install MySQL Workbench on your system to manage databases using a graphical interface instead of command-line tools.

To create a database through MySQL Workbench follow the below steps:

Step 1: Open MySQL Workbench

Search for MySQL Workbench in the Start menu and open the application.

Method2_MYSQLWorkBench_Step1

Step 2: Create a Local Connection

Click on the MySQL instance connection icon to create a new local connection.

Method2_MYSQLWorkBench_Step2

Step 3: Configure Connection

Enter Local as the connection name and click Test Connection.

Method2_MYSQLWorkBench_Step3

Step 4: Enter Password

Provide the MySQL password that you set during MySQL installation.

Method2_MYSQLWorkBench_Step4

Step 5: Verify Connection

If the connection is successful, a confirmation message will appear.

Method2_MYSQLWorkBench_Step5

Step 6: Open the Connection

Click on the Local instance connection to open the database dashboard.

Method2_MYSQLWorkBench_Step6

Step 7: Create Database Schema

Click the Create Schema icon in the toolbar.

Method2_MYSQLWorkBench_Step7

Step 8: Enter Database Details

Enter the database name and optionally select character set and collation, then click Apply.
Method2_MYSQLWorkBench_Step8

Step 9: Apply Settings

Click Apply again without changing the default settings.

Method2_MYSQLWorkBench_Step9

Step 10: Finish Database Creation

Click Finish to complete the database creation process.

Method2_MYSQLWorkBench_Step10

Step 11: View Created Database

You will now see the created database listed in the left-side schema panel.

Method2_MYSQLWorkBench_Step11

Step 12: Set Default Schema

Right-click on the database you created and click on Set, as Default Schema to use your database. Now your database is ready to use.

Method2_MYSQLWorkBench_Step12

Comment

Explore