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; Example: mysql> create database tastethelinux; OUTPUT: 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; OUTPUT: +----------------------------------+ | 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; OUTPUT: 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 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.
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.
When the connection got created, we can double click on the connection to connect to the MySQL Server.
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.
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,
- Query Tab to write and execute the Query.
- Result Grid for Results of the Output.
- 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.”