Secure Your Data: Install MariaDB on Rocky Linux 8
This tutorial provides instructions for installing MariaDB, a popular open-source relational database management system, on Rocky Linux 8. MariaDB is known for its security features and performance optimizations.
rocky linuxMariaDB
Nano
VPS
1
vCPU
1 GB
Memory
10 GB
NVMe Disk
512 GB
Traffic
2.90€
/month
* Up to 3GB RAM, 30GB NVMe Disk Space and 1Gbit/s Network Speed
#### Prerequisites
Before you begin, ensure you have:
- A server running Rocky Linux 8
- SSH access to your server with sudo privileges
- Basic familiarity with the command line and package management on Rocky Linux
#### Step 1: Install MariaDB
Install MariaDB server using DNF package manager:
```bash
sudo dnf install mariadb-server
```
#### Step 2: Start and Enable MariaDB
Start the MariaDB service and enable it to start on boot:
```bash
sudo systemctl start mariadb
sudo systemctl enable mariadb
```
#### Step 3: Secure MariaDB Installation
Run the MySQL secure installation script to improve security:
```bash
sudo mysql_secure_installation
```
Follow the on-screen prompts to set a root password, remove anonymous users, disallow root login remotely, and remove test databases.
#### Step 4: Access MariaDB
Access the MariaDB shell as the root user to verify the installation:
```bash
sudo mysql -u root -p
```
Enter the root password you set during the secure installation.
#### Step 5: Optional: Create a New Database and User
Create a new database and user with appropriate privileges:
```sql
CREATE DATABASE dbname;
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON dbname.* TO 'username'@'localhost';
FLUSH PRIVILEGES;
```
Replace `dbname`, `username`, and `password` with your preferred database name, username, and password.
#### Conclusion
You have successfully installed MariaDB on Rocky Linux 8, ensuring a secure foundation for your database operations. Begin using MariaDB to store and manage your data efficiently.
**Additional Resources:**
- **MariaDB Documentation:** [https://mariadb.org/documentation/](https://mariadb.org/documentation/)
- **Rocky Linux Documentation:** [https://docs.rockylinux.org/](https://docs.rockylinux.org/)