Install & Uninstall MariaDB (MySQL) on Kali Linux: Complete Tutorial
Video Tutorial
This comprehensive guide will walk you through the process of installing and configuring MariaDB (a drop-in replacement for MySQL) on Kali Linux. MariaDB is a popular open-source relational database server that maintains full compatibility with MySQL while offering enhanced features and performance.
Prerequisites
Before we begin, ensure you have:
- A running Kali Linux system
- Sudo privileges
- An active internet connection
🚀 Step 1: Update Your System
First, let’s make sure your system is up to date:
1
2
sudo apt update
sudo apt upgrade -y
📦 Step 2: Install MariaDB
Install MariaDB server and client packages:
1
sudo apt install mariadb-server mariadb-client -y
🔒 Step 3: Secure Your Installation
After installation, run the security script to configure basic security settings:
1
sudo mariadb-secure-installation
During this process, you’ll be prompted to:
- Set a root password
- Remove anonymous users
- Disallow root login remotely
- Remove test database
- Reload privilege tables
🏃♂️ Step 4: Start and Enable MariaDB Service
Start the MariaDB service and enable it to run on boot:
1
2
sudo systemctl start mariadb
sudo systemctl enable mariadb
Verify the service status:
1
sudo systemctl status mariadb
🔍 Step 5: Verify Installation
Test your MariaDB installation by connecting to the server:
1
sudo mysql -u root -p
If everything is working correctly, you’ll see the MariaDB prompt.
📝 Basic MariaDB Commands
Here are some useful commands to get started:
1
2
3
4
5
6
7
8
9
10
11
12
-- Show databases
SHOW DATABASES;
-- Create a new database
CREATE DATABASE mydatabase;
-- Create a new user
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword';
-- Grant privileges
GRANT ALL PRIVILEGES ON mydatabase.* TO 'myuser'@'localhost';
FLUSH PRIVILEGES;
🗑️ Uninstalling MariaDB
If you need to remove MariaDB from your system, follow these steps:
- Stop the MariaDB service:
1
sudo systemctl stop mariadb
- Remove MariaDB packages:
1
sudo apt remove --purge mariadb-server mariadb-client mariadb-common -y
- Remove configuration files and data directories:
1 2
sudo rm -rf /etc/mysql sudo rm -rf /var/lib/mysql
- Remove any remaining MariaDB packages:
1
sudo apt autoremove -y
- Clean up any remaining configuration files:
1
sudo apt clean
📚 Resources
- MariaDB Official Documentation
- MariaDB Knowledge Base
- MySQL Documentation (compatible with MariaDB)