Skip to content Skip to sidebar Skip to footer

Guide How to Create a Database in Windows CMD (Beginners)

A database can be likened to a library containing various types of books. Libraries are databases, while books are data. If you have ever visited a library, you must have seen that every book in the library is neatly grouped to make it easier for visitors to find books.

One type of database that is commonly used is the relational database, whose idea was born in 1970 from the thoughts of an IBM programmer named EF Codd. A relational database consists of tables whose row and column arrangements are similar to tables in Excel. Each cell is called a field and each row is called a record.

The function of tables in a relational database is to store data. The data in the table can be deleted, retrieved and updated at any time. To do all that, we need a software that can communicate with all the data. Such software is called the Relational Database Management System (RDBMS) and some of them that you can use are MySQL, Oracle, SQLite and IBM DB2. You can also create a database in CMD.

Tutorial How to Create a Database in CMD

Here I will explain about how to create a database in CMD starting from creating databases, tables to entering data or records in tables. Check out the steps below:

1. To create a database in CMD, you need an application called XAMPP. You can download XAMPP via this link then install it as usual. After that open the XAMPP application then run the service Apache, MySQL and FileZilla by clicking the button Start.

Creating a Database in CMD 1

2. Usually the XAMPP installation folder will be located on the C: partition with a folder named xampp.

How to Create a Database in CMD

3. Next you open CMD via the Start Menu.

Creating a Database in CMD 3

4. Then run these commands one by one:

cd..cd..cd xamppcd mysqlcd bin

How to Create a Database in Windows CMD

5. After that run this command to access MySQL as root. After that you have successfully logged into your MySQL.

mysql -u root

Creating a Database in CMD 5

6. To start creating a database, you can run the command CREATE DATABASE databasename; then press Enter. Don’t forget to end each command with ;

CREATE DATABASE nesabamedia;

How to Create a Database in CMD MySQL

7. To access the database that we have created, the following command.

USE nesabamedia;

Creating a Database in CMD 7

8. In the database of course there must be a table to store data. To create a table, run this command one by one. Here I want to create a table named absent which consists of 5 fields including: NISN, Class, Name, Gender and Department. If it says Query OK means the command was executed successfully / no error.

CREATE TABLE absen (NISN int,Kelas int,Nama varchar (60),Jenis_kelamin varchar (10),Jurusan varchar (25));

Creating a Database in CMD 8

9. Now we will enter data in the table that we have created. If the intended data is a varchar, there must be an apostrophe ‘Ari Purwanto’. It’s easier to just run this command.

INSERT INTO absen (NISN, Kelas, Nama, Jenis_kelamin, Jurusan) values (1172271,12,'Ari Purwanto', 'Laki-laki', 'Multimedia');

When entering data in the table, it must be in order so that the data is added according to the column or field. You are free to determine how much data you want to include in the table. For example below I only enter 5 data only, or in the database created 5 records.

Creating a Database in CMD 9

10. How do I view the data or records that we have entered? The method is simple, just run the command:

SELECT * FROM absen;

The result will be like this:

Creating Databases in CMD 10

Closing

No matter how complete the data you have, as long as you just collect the data, then the data might actually make you bothered. By entering all data into the database, searching for data will be much easier. For example, by using a database, a company can easily find employees who have exceeded sales targets within a certain period.

You can also create more than one table where each table contains different but still related information. For example, employee table and attendance table. From the two tables, by taking advantage of the relationship between the two, you can cross-reference to obtain the information you need.

One of them is information about who among the employees has the most or the least number of absences in one year. Information like this can only be obtained if you have a well-structured database.

Post a Comment for "Guide How to Create a Database in Windows CMD (Beginners)"