如何在 Kali Linux 2022.x 上安装 MariaDB 10.6 |
在今天的指南中,我们将讨论如何在 Kali Linux (2022.x) 版本上安装 MariaDB 10.6。 MariaDB 是 MySQL 的直接替代品,具有更多功能、新存储引擎和更好的性能。您可以从项目网站获取有关 MariaDB 10.6 功能的所有详细信息。
截至本文撰写时,MariaDB 10.6 是可安装在 Linux 和某些 BSD 系统上的 MariaDB 数据库管理系统的最新稳定版本。在 Kali Linux 上安装 MariaDB 之前,我们将添加官方 MariaDB apt 存储库,然后从中安装所有依赖项和实际的 MariaDB 软件包。
第1步:更新系统
让我们确保我们的系统已更新。
sudo apt update
如果您可以更新所有已安装的软件包,则可以运行升级命令,然后重新启动系统。
sudo apt upgrade
sudo reboot
步骤 2:将 MariaDB APT 存储库添加到 Kali Linux
我们将使用 Debian 11 (Bullseye) 的 MariaDB apt 存储库。确保安装以下软件依赖项。
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.6/debian bullseye main" | sudo tee /etc/apt/sources.list.d/mariadb.list
然后在 Kali Linux 上实际安装 MariaDB 之前更新您的 APT 索引。
$ sudo apt update
Hit:1 http://ftp.halifax.rwth-aachen.de/kali kali-rolling InRelease
Get:2 http://mariadb.mirror.liquidtelecom.com/repo/10.6/debian bullseye InRelease [4634 B]
Get:3 http://mariadb.mirror.liquidtelecom.com/repo/10.6/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:在Kali Linux上安装MariaDB 10.6
添加存储库后,我们可以使用 apt 包管理器在 Kali Linux 上安装 MariaDB 服务器和客户端软件包。
确认存储库中是否有可用的包:
$ apt policy mariadb-server
mariadb-server:
Installed: (none)
Candidate: 1:10.6.7+maria~bullseye
Version table:
1:10.6.7+maria~bullseye 500
500 http://mariadb.mirror.liquidtelecom.com/repo/10.6/debian bullseye/main amd64 Packages
1:10.6.5+maria~bullseye 500
500 http://mariadb.mirror.liquidtelecom.com/repo/10.6/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.6/debian bullseye/main amd64 Packages
在Kali Linux系统上安装MariaDB 10.6
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 2022-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
Udemy 上最佳 MySQL 学习课程:
- 终极 MySQL 训练营:从 SQL 初学者到专家
- SQL – 用于数据分析和商业智能的 MySQL
- MySQL、SQL 和存储过程(从初级到高级)
- SQL 初学者:使用 MySQL 和数据库设计学习 SQL
- 完整的 MySQL 开发人员课程
- MySQL 数据库管理:初级 SQL 数据库设计
- 学习 MySQL 数据库设计
更多关于 Kali Linux 的信息。
- 在 Kali Linux 上安装 Nessus 漏洞扫描器
- 在 Kali Linux 上安装 Metasploit 框架
- 在 Kali Linux 上安装 Docker 和 Docker Compose
- 将 Kali Linux 官方存储库添加到sources.list