What is a Database and How to Create One in CMD

What is a Database and How to Create One in CMD


What is a Database?

A database is a systematic collection of information stored in a computer so that it can be examined using a computer program to obtain information from the database.

The term database originated from computer science and refers to a collection of interrelated data, and its software should be referred to as a database management system. Records similar to databases actually existed before the industrial revolution in the form of ledgers, receipts, and collections of business-related data.

The basic concept of a database is a collection of records or pieces of knowledge. A database has a structured description of the types of facts stored within it.

Conceptually, a database is a collection of data that forms interrelated files (relations) with specific procedures to form new data or information. Or, a database is a collection of interrelated data organized based on a certain schema or structure.

What is a Database and How to Create One in CMD

Creating a Database in CMD

When creating a database, two methods are commonly used. First, creating a database using CMD, and second, creating a database directly in its GUI, such as in phpMyAdmin found in XAMPP. This time, we will create a database using CMD/Terminal.

Read Also: Creating a Database and Database Tables in XAMPP phpMyAdmin

Before you start creating a database, don’t forget to install MySQL. For Linux users, run the command sudo apt-get install mysql in the Terminal. For macOS users, run the command brew install mysql. For Windows users, simply install XAMPP, as it includes a complete package. :D

Step One

Before creating a database, we must log in to MySQL first. To access MySQL, run the following command:

mysql -u root

The command above is for logging in using the default user root so we don’t need to look for an unknown password. If you already know your MySQL login password, you can run the command mysql -u root -p.

Step Two

After successfully logging in, we will see the default content in the MySQL database and we will directly create a database, along with several ways to insert data into database tables and delete table data, as follows:

Creating a Database in MySQL CMD

In the image above, there are several commands: show databases; to display the database content in MySQL and the command create database testDB; to create a new database.

Step Three

In this step, we will create a table, fill it with data, and display all the data in the table, as shown in the image below:

Creating Tables and Inserting Data in MySQL

The output is as shown above. Other methods for creating tables in XAMPP are not much different from the tutorial in this article. Stay tuned for further installments of this series—don’t forget to visit the KuasaiTeknologi blog. Hope this is useful for everyone!