DEBIAN 11 DATABASE
A. Learning objectives:
B. Preparation of Tools and Materials:
-VMware Workstation/VMware Player
-ISO Debian 11 (can be downloaded from https://www.debian.org/distrib/)
Minimum Specifications:
RAM: 2 GB (recommended 4 GB)
Storage: 20 GB
Processor: Dual-core
Installation process:
1. Install Maria-DB, for example install MariaDB by typing the command apt install mariadb-server mariadb-client. This command is used to install the MariaDB database software and its client on a Debian-based operating system.
2. Then restart maria-db with the command systemctl restart maria-db, then check the maria-db status with the command systemctl status maria-db, then enter. If the configuration is correct, the active running status will appear.
3. Once MariaDB has been successfully installed, the next important step is to secure the installation by running the mysql_secure_installation command. This command will start MariaDB's built-in security script that aims to improve the protection of your database server. When run, you will be prompted to set several configurations, such as setting a password for the root user if it is not already set, removing anonymous users, disabling remote root access, deleting the test database, and reloading the privilege tables. All of these steps are important to prevent unauthorized access, especially if the server is used in a production environment. It is highly recommended to answer “yes” to most of the questions to ensure that your MariaDB server is secure.
Page 1
Page 2
5. At this stage, we will start configuring MariaDB by creating a new database. After the security process is complete, we can access the MariaDB shell by running the command mysql -u root -p. This command is used to enter the MariaDB interface via the terminal as the root user.
6. SQL commands in MariaDB to create a database, user, and grant access rights. Here is the explanation per line:
1. CREATE DATABASE db_satria;
Create a new database with the name db_satria.
2. CREATE USER 'satria'@'localhost' IDENTIFIED BY '123';
Create a new user named satria, who can only log in from localhost.
The password for this user is '123'.
3. GRANT ALL PRIVILEGES ON db_satria.* TO 'satria'@'localhost';
Grant all access rights (ALL PRIVILEGES) to all tables in the db_satria database to the satria user.
4. FLUSH PRIVILEGES;
Reload the access rights (privileges) so that the changes that have been made take effect immediately.
7. The SHOW DATABASES command; is used to display all databases available on the MariaDB server. From the results of the command, it can be seen that there are four databases, namely db_satria, information_schema, mysql, and performance_schema. The db_satria database is a database created by the user, while the other three are system default databases. information_schema contains metadata about the database such as table and column structures, mysql stores important information related to users and access rights, while performance_schema is used to monitor the performance of the database system. These results indicate that the db_satria database has been successfully created and the MariaDB system is running normally.
8. create a new table in the db_satria database with the table name daftar_siswa. This table is created with the CREATE TABLE command and has several columns, namely ID, Name, Age, Class, and Address. The ID column is of type INT, uses the AUTO_INCREMENT attribute so that its value increases automatically in each new row, and is set as the PRIMARY KEY which functions as a unique identity for each row of data. The Name column is of type VARCHAR (100), Age is of type INT, Class is of type VARCHAR (50), and Address is of type TEXT. After the table is successfully created, the SHOW TABLES; command is used to display all tables in the db_satria database, and the result is that the daftar_siswa table is successfully created.
9. The INSERT INTO command in the image is used to add three rows of data to the student_list table in the db_satria database. In this command we determine the columns to be filled, namely Name, Age, Class, and Address, then provide three sets of values for each column: the first row contains the data "Muhammad Satria Bayu Aji", age 17 years, class "XI TKJ B", address "Jl. Bintara 9 No. 124, Bekas Barat"; the second row "Meisa Syakila", age 16 years, class "XI TKJ 3", address "Jl. H.alam 2 No. 70, Bekas Barat"; and the third row "Salamah", age 17 years, class "XI TKJ 4", address "Jl. H.alam 3 No. 71, West Bekasi". After the command is executed, the MariaDB server confirms that the three rows were successfully added without duplication or warnings.
10. The SELECT * FROM student_list; command displays all data stored in the daftar_siswa table, including the ID, Name, Age, Class, and Address columns. The results show three rows of student data: the first row with ID 1 in the name of Muhammad Satria Bayu Aji aged 17 years in class XI TKJ B with the address "Jl. Bintara 9 No. 124, West Bekasi"; the second row ID 2 in the name of Meisa Syakila aged 16 years in class XI TKJ 3 with the address "Jl. H.alam 2 No. 70, West Bekasi"; and the third row ID 3 in the name of Salamah aged 17 years in class XI TKJ 4 with the address "Jl. H.alam 3 No. 71, West Bekasi". These results confirm that the data has been successfully entered and can be accessed according to the table structure.