Table of Contents[Hide][Show]
MariaDB is a popular open-source relational database management system (RDBMS) that is widely used for managing and organizing data. It is a fork of MySQL and is known for its performance, scalability, and ease of use. If you are using Kali Linux, a Debian-based distribution tailored for penetration testing and security research, you might need to install MariaDB for various purposes, such as setting up a local database for testing or development.
In this article, we will walk you through the step-by-step process of how to install MariaDB on Kali Linux. We will cover everything from updating your system to securing your MariaDB installation. By the end of this guide, you will have a fully functional MariaDB server running on your Kali Linux machine.
Why Choose MariaDB?
MySQL has been a leading relational database management system (RDBMS) for years. However, after its acquisition by Oracle Corporation, concerns arose about its open-source future.
MariaDB was created as a community-driven, open-source alternative by MySQL’s original co-founder, Michael “Monty” Widenius, and other developers. Backed by Monty Program AB and the MariaDB Foundation, it remains independent, transparent, and free from vendor lock-in.
Key Reasons to Use MariaDB:
- Truly Open Source: Ensures transparency and community-driven development.
- Led by MySQL’s Original Developers: Built by experts committed to innovation.
- Better Performance & Features: Includes advanced storage engines and optimizations.
- MySQL Compatibility: Seamless migration with minimal changes.
- Strong Community Support: The MariaDB Foundation ensures long-term sustainability.
MariaDB is a powerful, high-performance alternative to MySQL, offering enhanced features and a commitment to open-source principles.
Who Uses MariaDB?
MariaDB is a preferred database solution for a diverse range of organizations, Linux distributions, and large-scale websites due to its reliability, high performance, and open-source flexibility. Many industry leaders and technology platforms have adopted MariaDB, leveraging its advanced features and seamless MySQL compatibility.
Notable Users of MariaDB
Websites & Platforms | Linux Distributions | Other Organizations |
---|---|---|
OpenSUSE | OLX | |
Amazon Web Services (AWS) | Fedora | Nimbuzz |
Arch Linux | SlashGear | |
Mozilla Corporation | Red Hat Enterprise Linux (RHEL 7+) | |
Wikipedia | Manjaro | |
Mageia | ||
Debian | ||
The Chakra Project | ||
Gentoo | ||
OpenBSD |
These organizations and distributions trust MariaDB for its superior performance, scalability, and active community support. Its MySQL compatibility makes it an ideal choice for smooth migrations while offering cutting-edge database technology. Whether powering large-scale web applications or serving as the default database for Linux distributions, MariaDB remains a trusted and versatile solution across industries.
Prerequisites
Before we dive into the installation process, ensure that you have the following:
- Kali Linux Installed: You should have a working installation of Kali Linux. This guide assumes you are using a recent version of Kali Linux.
- Sudo Privileges: You need administrative privileges to install and configure software on your system.
- Stable Internet Connection: The installation process requires downloading packages from the internet.
How to Install MariaDB on Kali Linux
Step 1: Update Your System
Before installing any new software, it is always a good practice to update your system to ensure that all existing packages are up to date. Open a terminal and run the following commands:
sudo apt update sudo apt upgrade -y
This will update the package list and upgrade any outdated packages on your system.
Step 2: Install MariaDB on Kali Linux
MariaDB is available in the default Kali Linux repositories, making the installation process straightforward. To install MariaDB, follow these steps:
Install the MariaDB Server Package: Run the following command to install the MariaDB server:
sudo apt install mariadb-server -y
This command will install the MariaDB server along with any necessary dependencies.
Verify the Installation: Once the installation is complete, you can verify that MariaDB is installed by checking its version:
mariadb --version
This command will display the installed version of MariaDB, confirming that the installation was successful.
Step 3: Start and Enable MariaDB Service
After installing MariaDB, you need to start the MariaDB service and enable it to start automatically on system boot.
Start the MariaDB Service: Run the following command to start the MariaDB service:
sudo systemctl start mariadb
Enable MariaDB to Start on Boot: To ensure that MariaDB starts automatically whenever your system boots, enable the service:
sudo systemctl enable mariadb
Check the Status of MariaDB: You can verify that the MariaDB service is running by checking its status:
sudo systemctl status mariadb
If the service is running, you should see an output indicating that it is active.
Step 4: Secure Your MariaDB Installation
By default, MariaDB is not secured, and it is essential to run a security script to set a root password, remove anonymous users, and disable remote root login. Follow these steps to secure your MariaDB installation:
Run the MariaDB Security Script: Execute the following command to start the security script:
sudo mysql_secure_installation
Follow the Prompts: The script will guide you through several steps:
- Set a Root Password: You will be prompted to set a password for the MariaDB root user. Choose a strong password and confirm it.
- Remove Anonymous Users: The script will ask if you want to remove anonymous users. It is recommended to answer
Y
(Yes). - Disallow Root Login Remotely: You will be asked if you want to disallow root login remotely. Answer
Y
(Yes) to enhance security. - Remove the Test Database: The script will prompt you to remove the test database. Answer
Y
(Yes) unless you need it. - Reload Privilege Tables: Finally, the script will ask if you want to reload the privilege tables. Answer
Y
(Yes) to apply the changes. Once the script completes, your MariaDB installation will be more secure.
Step 5: Access MariaDB
Now that MariaDB is installed and secured, you can access it using the MySQL command-line client.
Log in to MariaDB: Run the following command to log in to MariaDB as the root user:
sudo mysql -u root -p
You will be prompted to enter the root password you set during the security script.
Create a New Database and User: Once logged in, you can create a new database and user. For example:
CREATE DATABASE testdb;
CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON testdb.* TO 'testuser'@'localhost';
FLUSH PRIVILEGES;
Replace testdb
, testuser
, and password
with your desired database name, username, and password.
Exit MariaDB: To exit the MariaDB shell, type:
EXIT;
Step 6: Configure MariaDB (Optional)
Depending on your use case, you may want to configure MariaDB further. The main configuration file for MariaDB is located at /etc/mysql/mariadb.conf.d/50-server.cnf
. You can edit this file to customize settings such as:
- Binding to a Specific IP Address: By default, MariaDB listens on
127.0.0.1
. If you want it to listen on a specific IP address, modify thebind-address
directive. - Adjusting Memory Settings: You can optimize MariaDB performance by adjusting memory-related settings such as
innodb_buffer_pool_size
.
After making changes to the configuration file, restart the MariaDB service to apply the changes:
sudo systemctl restart mariadb
Step 7: Test Your MariaDB Installation
To ensure that your MariaDB installation is working correctly, you can perform a simple test by creating a database, adding a table, and inserting some data.
Log in to MariaDB:
sudo mysql -u root -p
Create a Test Database:
CREATE DATABASE testdb;
USE testdb;
Create a Table:
CREATE TABLE users (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50), email VARCHAR(50));
Insert Data:
INSERT INTO users (name, email) VALUES ('John Doe', 'john@example.com');
Query Data:
SELECT * FROM users;
If the query returns the inserted data, your MariaDB installation is functioning correctly.
Step 8: Uninstall MariaDB (Optional)
If you ever need to uninstall MariaDB from your Kali Linux system, follow these steps:
Stop the MariaDB Service:
sudo systemctl stop mariadb
Remove MariaDB Packages:
sudo apt remove --purge mariadb-server -y
Remove Configuration Files:
sudo rm -rf /etc/mysql /var/lib/mysql
Remove Unused Dependencies:
sudo apt autoremove -y
Conclusion
In this guide, we have covered the step-by-step process of how to install MariaDB on Kali Linux. From updating your system to securing your MariaDB installation, we have provided detailed instructions to help you set up a fully functional MariaDB server. Whether you are a developer, security researcher, or database administrator, MariaDB is a powerful tool that can help you manage your data efficiently.
By following this guide, you should now have a working MariaDB installation on your Kali Linux machine. You can further explore MariaDB’s features and customize it to suit your specific needs. If you encounter any issues during the installation process, refer to the official MariaDB documentation or seek help from the community.