Як встановити MariaDB 10.x на Kali Linux

Як встановити MariaDB 10.x на Kali Linux

 

У нашому сьогоднішньому посібнику ми обговоримо, як ви можете встановити MariaDB 10.x у послідовному випуску Kali Linux. MariaDB – це заміна MySQL з більшою кількістю функцій, новими движками зберігання даних та кращою продуктивністю. Всі подробиці ви можете отримати на сайті MariaDB.

На момент написання цієї статті, MariaDB 10.6 є останнім стабільним релізом системи управління базами даних MariaDB, яка встановлюється на Linux і деякі системи BSD. Перед тим, як встановити MariaDB на Kali Linux, ми додамо офіційний репозиторій MariaDB apt, а потім встановимо з нього всі залежності та актуальні пакети MariaDB.

Крок 1: Оновіть систему

Давайте подбаємо про те, щоб наша система була оновлена.

sudo apt update

Якщо ви можете оновити всі встановлені пакети, ви можете виконати команду upgrade, а потім перезавантажити систему.

sudo apt upgrade
sudo reboot

Крок 2: Додайте репозиторій MariaDB APT до Kali Linux

Ми будемо використовувати apt репозиторій MariaDB для Debian 11 (Bullseye). Переконайтеся, що ви встановили наведені нижче залежності програмного забезпечення.

sudo apt -y install software-properties-common gnupg2

Потім додайте репозиторій MariaDB APT до Kali Linux.

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
echo "deb [arch=amd64] http://mariadb.mirror.liquidtelecom.com/repo/10.9/debian bullseye main" | sudo tee /etc/apt/sources.list.d/mariadb.list

Потім оновіть свій індекс APT перед фактичним встановленням MariaDB на Kali Linux.

$ sudo apt update
Hit:1 http://ftp.halifax.rwth-aachen.de/kali kali-rolling InRelease
Get:2 http://mariadb.mirror.liquidtelecom.com/repo/10.9/debian bullseye InRelease [4634 B]
Get:3 http://mariadb.mirror.liquidtelecom.com/repo/10.9/debian bullseye/main amd64 Packages [26.3 kB]
Fetched 31.0 kB in 1s (33.2 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
49 packages can be upgraded. Run 'apt list --upgradable' to see them.

Крок 3: Встановіть MariaDB 10.6 на Kali Linux

Після додавання репозиторію ми можемо встановити пакети програмного забезпечення сервера та клієнта MariaDB на Kali Linux за допомогою менеджера пакетів apt.

Підтвердьте, чи доступні пакунки в репозиторії:

$ apt policy mariadb-server
mariadb-server:
  Installed: (none)
  Candidate: 1:10.9.7+maria~bullseye
  Version table:
     1:10.6.7+maria~bullseye 500
        500 http://mariadb.mirror.liquidtelecom.com/repo/10.9/debian bullseye/main amd64 Packages
     1:10.6.5+maria~bullseye 500
        500 http://mariadb.mirror.liquidtelecom.com/repo/10.9/debian bullseye/main amd64 Packages
     1:10.6.5-2 500
        500 http://http.kali.org/kali kali-rolling/main amd64 Packages
     1:10.6.4+maria~bullseye 500
        500 http://mariadb.mirror.liquidtelecom.com/repo/10.9/debian bullseye/main amd64 Packages

Встановіть MariaDB 10.6 на систему Kali Linux

sudo apt update
sudo apt install mariadb-server

Запустіть і включіть сервіс mariadb після установки.

sudo systemctl enable --now mariadb

Підтвердьте, що послугу запущено.

$ systemctl status mariadb                                                                                                                                                                                          
mariadb.service - MariaDB 10.6.7 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
    Drop-In: /etc/systemd/system/mariadb.service.d
             └─migrated-from-my.cnf-settings.conf
     Active: active (running) since Wed 2024-02-16 08:15:51 EST; 5s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 27048 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 27049 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 27051 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_>
    Process: 27096 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 27098 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
   Main PID: 27080 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 17 (limit: 9444)
     Memory: 84.2M
        CPU: 592ms
     CGroup: /system.slice/mariadb.service
             └─27080 /usr/sbin/mariadbd

Feb 16 08:15:53 kali /etc/mysql/debian-start[27104]: performance_schema
Feb 16 08:15:53 kali /etc/mysql/debian-start[27104]: sys
Feb 16 08:15:53 kali /etc/mysql/debian-start[27104]: Phase 6/7: Checking and upgrading tables
Feb 16 08:15:53 kali /etc/mysql/debian-start[27104]: Processing databases
Feb 16 08:15:53 kali /etc/mysql/debian-start[27104]: information_schema
Feb 16 08:15:53 kali /etc/mysql/debian-start[27104]: performance_schema
Feb 16 08:15:53 kali /etc/mysql/debian-start[27104]: sys
Feb 16 08:15:53 kali /etc/mysql/debian-start[27104]: sys.sys_config                                     OK
Feb 16 08:15:53 kali /etc/mysql/debian-start[27104]: Phase 7/7: Running 'FLUSH PRIVILEGES'
Feb 16 08:15:53 kali /etc/mysql/debian-start[27104]: OK

Крок 4: Безпека MariaDB

Тепер запустіть безпечний скрипт, щоб встановити пароль root, видалити тестову базу даних і відключити віддалений вхід користувача root.

$ sudo mysql_secure_installation 

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] n
Enabled successfully!
Reloading privilege tables..
 ... Success!


You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Тепер вам потрібно вказати ім’я користувача та пароль для доступу до консолі MySQL. Без автентифікації ви отримаєте помилку “Відмовлено в доступі”.

$ mysql -u root
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

Використовуйте параметр -p для автентифікації:

$ mysql -u root -p                                                                                                                                                                                                    
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 55
Server version: 10.5.8-MariaDB-1:10.5.8+maria~buster mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SELECT VERSION();
+--------------------------------------+
| VERSION()                            |
+--------------------------------------+
| 10.5.8-MariaDB-1:10.5.8+maria~buster |
+--------------------------------------+
1 row in set (0.000 sec)

MariaDB [(none)]> \q
Bye
Прокрутка до верху