How to Create New Database in MySQL Workbench

Mehvish Ashiq Feb 02, 2024
  1. Create New Database Using MySQL Workbench
  2. Create New Database Using MySQL Workbench - Using Menu Bar
  3. Create New Database Using MySQL Workbench - Using SQL Query
  4. Create New Database Using MySQL Workbench - Using Navigator
  5. Create New Database Using MySQL Workbench - Using Command Prompt
  6. Conclusion
How to Create New Database in MySQL Workbench

MySQL Workbench is a visual tool for programmers and database architects to make their job easy. The Graphical User Interface of MySQL Workbench saves time and effort and lets the user focus on productivity rather than struggling with queries.

It is important to know that database is also known as Schema in MySQL Workbench. We will see different ways to have a new database using a navigator, SQL query, and menu bar.

This article will also show you how you can create a new database using Command Prompt. We are using MySQL Workbench Version 8.27 for this tutorial (you may get the latest version from here)

Create New Database Using MySQL Workbench

To create a new database, you have to launch the MySQL Workbench first.

create new database in mysql workbench - launch mysql workbench

There can be multiple connections if you have created them. If there is no connection, then click on ‘+’ (Plus sign) highlighted in the red box and create a connection as follows.

create new database in mysql workbench - create a connection

Write the connection name of your choice. Default Port number is 3306 for MySQL, but you can change it in case if it is already occupied, then click on Test Connection. The following screen will appear.

create new database in mysql workbench - enter password

Enter the password that you used during MySQL Workbench installation and click OK. You will see the following message; click OK again.

create new database in mysql workbench - connected created successfully

Now, you can see your connection as follows.

create new database in mysql workbench - connections

Create New Database Using MySQL Workbench - Using Menu Bar

Click on your connection; it will open the window as follows. Click on the Database icon in the menu bar (highlighted in red in the following screenshot).

create new database in mysql workbench - create database using menu bar part a

You will see the following screen, name your schema, and click Apply button.

create new database in mysql workbench - create database using menu bar part b

The following window will open; click Apply. Please note that you can also write more SQL queries in the red box.

create new database in mysql workbench - create database using menu bar part c

The following window will show up; click on Finish.

create new database in mysql workbench - create database using menu bar part d

Now, you can see your Schema a.k.a. Database under the Navigator window (see the following screenshot). Please note that the other database named sys is the default database.

create new database in mysql workbench - create database using menu bar part e

Create New Database Using MySQL Workbench - Using SQL Query

To create a new database using SQL query, follow the steps given in the following screenshot. First, create a SQL file (red box number 1 in the following screenshot), write the commands (red box number 2), press the refresh button (red box number 3), and see the recently created schemas (red box number 4).

You may have noticed that the database can be created using both commands CREATE SCHEMA DB_name; and CREATE DATABASE DB_name; in MySQL Workbench.

create new database in mysql workbench - create database using sql query

Create New Database Using MySQL Workbench - Using Navigator

You can also create a database from the Navigator pane. Right click in the Navigator pane, select Create Schema, name your database, and click apply (as we already did in method 1).

create new database in mysql workbench - create database using navigator

Create New Database Using MySQL Workbench - Using Command Prompt

Open your command prompt as an administrator. Go to the path where MySQL is installed and use the following command to login:

mysql -u root -p 12345

Here -u means username, -p means password. Our username is the root, and the password is 12345, yours may be different.

create new database in mysql workbench - create database using cmd part a

Right now, we have the following databases.

create new database in mysql workbench - create database using cmd part b

Write the SQL command for creating a new database and make sure whether it is created or not.

create new database in mysql workbench - create database using cmd part c

The newly created database named db_creating_from_cmd is listed in the above screenshot. Let’s see in MySQL Workbench as well, and it is there (see the following screenshot).

create new database in mysql workbench - create database using cmd part d

Conclusion

We have concluded that working in MySQL Workbench is so easy. It just needs a little bit of practice.

There are different options within the MySQL Workbench to create a new database. It includes creating a database using navigator pane, menu bar and SQL command. You can also create a new schema using the command prompt as well.

Mehvish Ashiq avatar Mehvish Ashiq avatar

Mehvish Ashiq is a former Java Programmer and a Data Science enthusiast who leverages her expertise to help others to learn and grow by creating interesting, useful, and reader-friendly content in Computer Programming, Data Science, and Technology.

LinkedIn GitHub Facebook

Related Article - MySQL Workbench