How to create a database in MySQL with GUI and CLI.


This tutorial is for MySQL, How to Create Database with GUI and CLI.

GUI tools to connect with MySQL like Workbench, Beekeeper Studio, dbForge Studio, etc.

So let’s use Workbench for the GUI and Linux Command line for the command line.

Before creating the database, if you want to set up MySQL in Linux, please refer to the following link.

So the topic that will be cover into this tutorial are as follows,

  • How to create database in MySQL with CLI.
  • How to create database in MySQL with GUI (Workbench).

If you want to upgrade MySQL version to another version then refer the link.

How to create database in MySQL with CLI

Creating a database from the CLI is the easiest way take login first on the Command Line Prompt.

$ mysql -h localhost -uUsername -pPassword

-h: This parameter is to connect MySQL. Suppose I have an RDS setup on AWS, then put the RDS host instead of localhost.

-u: Put the Username for the MySQL.

-p: Put the Password for MySQL.

mysql> create database name_of_the_Database;

mysql> create database tastethelinux;

Query OK, 1 row affected (0.22 sec)

Then check the created database by “show databases”. you can see the created database.

mysql> show databases;

 | Database                          |
 | information_schema    |
 | mysql                                 |
 | performance_schema  |
 | sys                                      |
 | tastethelinux                  |
5 rows in set (0.01 sec)

To connect the database USE statement will be there in MySQL.

> use tastethelinux;

Database changed

Now you can check the tables use the Select, Update, delete or insert Queries.

How to Create a Database using MySQL Workbench(GUI).

So to create a database in GUI, make the connection then connect with that connection.

Click on + sign to add the mysql service connection, to create a database.

Click on the “+” symbol to add the connection for MySQL Server. It can be the localhost, RDS Server, or any instance running on the VM.

So for our example, we have set up the MySQL server into a local system.

Put the hostname, port number, username and password for the connection.

So fill the required details like “Connection Name”, “Hostname”, “Port”, “Username” and “Password”.

Click on “Test Connection”, and you will get the prompt connection established.

Connection created in MySQL Workbench.

When the connection got created, we can double click on the connection to connect to the MySQL Server.

Double click on the connection it will ask for the password in Workbench.

After it will prompt for the password, then put the password you had set up at the time of MySQL.

Then you will see a Query Tab in the MySQL Workbench, In which we have to execute our Query.

Then in the Query tab, create the Database in MySQL with the create database Statement.

Now let’s Execute the Query to create a Database and show the databases.

> create database tastethelinux;

> show databases;

In MySQL workbench, there are 3 columns,

  1. Query Tab to write and execute the Query.
  2. Result Grid for Results of the Output.
  3. Action Output has the action performed on the server.

If you want to learn more about mysql, then refer to the link.

One Reply to “How to create a database in MySQL with GUI and CLI.”

Give your valuable time