월. 8월 4th, 2025

If you’re setting up a database server on Linux, MariaDB (a popular MySQL fork) is a reliable, open-source choice. This guide covers installation on Ubuntu/Debian and CentOS/RHEL-based systems.


Prerequisites

  • Terminal access with sudo privileges
  • Stable internet connection
  • Basic Linux command familiarity

1. Ubuntu/Debian Installation

Step 1: Update System Packages

sudo apt update && sudo apt upgrade -y  

Step 2: Install MariaDB

sudo apt install mariadb-server -y  

Step 3: Enable Automatic Startup

sudo systemctl enable mariadb  

2. CentOS/RHEL Installation

Step 1: Add MariaDB Repository

sudo curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash -s -- --mariadb-server-version=11.2  

Step 2: Install MariaDB

sudo yum install MariaDB-server -y  

Step 3: Start and Enable Service

sudo systemctl start mariadb  
sudo systemctl enable mariadb  

3. Secure Your Installation

Run the security script after installation:

sudo mysql_secure_installation  

Follow prompts to:

  1. Set a strong root password.
  2. Remove anonymous users.
  3. Disallow remote root login (recommended).
  4. Remove test databases.
  5. Reload privileges.

4. Basic MariaDB Management Commands

  • Start/Stop/Restart Service:
    sudo systemctl start|stop|restart mariadb  
  • Check Status:
    sudo systemctl status mariadb  
  • Access MySQL Shell:
    sudo mysql -u root -p  

5. Verify Installation

Connect to MariaDB and check the version:

sudo mysql -u root -p -e "SELECT VERSION();"  

Expected output:

+-------------------+  
| VERSION()         |  
+-------------------+  
| 11.2.2-MariaDB... |  
+-------------------+  

6. Troubleshooting Tips

  • Connection Refused? Ensure MariaDB is running (systemctl status mariadb).
  • Password Issues? Reset root password:
    sudo mysql_secure_installation  
  • Firewall Blocking? Open port 3306:
    sudo ufw allow 3306/tcp  # Ubuntu  
    sudo firewall-cmd --add-port=3306/tcp --permanent  # CentOS  

Conclusion

You’ve now installed MariaDB on Linux! Next steps:

  • Create databases/users: CREATE DATABASE mydb;
  • Grant privileges: GRANT ALL ON mydb.* TO 'user'@'localhost' IDENTIFIED BY 'password';
  • Backup databases: mysqldump -u root -p mydb > backup.sql

MariaDB’s compatibility with MySQL makes it ideal for applications like WordPress, Nextcloud, or custom projects. Check the official documentation for advanced configurations.

> Pro Tip: Use mariadb-backup for enterprise-level backups and always keep your system updated!

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다