How to Install MariaDB on Rocky Linux
Step 1: Update Your System
Before installing MariaDB, update your system to ensure you have the latest package information:
sudo dnf update -y
Step 2: Install MariaDB Server
Install MariaDB Server on Rocky Linux using the following command:
sudo dnf install -y mariadb-server
Step 3: Start and Enable MariaDB
Start the MariaDB service and enable it to start automatically on boot:
sudo systemctl start mariadb
sudo systemctl enable mariadb
Step 4: Secure Your MariaDB Installation
Run the MariaDB secure installation script to secure your installation:
sudo mysql_secure_installation
Follow the prompts to set a root password and secure your MariaDB installation.
Step 5: Test MariaDB
Test your MariaDB installation by logging in as the root user:
sudo mysql -u root -p
Enter the root password you set during the secure installation.
Step 6: Create Databases and Users (Optional)
Create databases and user accounts as needed:
CREATE DATABASE mydatabase;
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword';
GRANT ALL PRIVILEGES ON mydatabase.* TO 'myuser'@'localhost';
FLUSH PRIVILEGES;
Step 7: Exit MariaDB
Exit the MariaDB console:
exit
Step 8: Start and Enable MariaDB on Boot
If MariaDB is not already running, start it and enable it to start automatically on boot:
sudo systemctl start mariadb
sudo systemctl enable mariadb
That's it! You've successfully installed and configured MariaDB on Rocky Linux. You can now use MariaDB to create databases, manage user accounts, and run SQL queries on your server.