Installing MariaDB

Installing MariaDB can vary slightly depending on the operating system you are using. In this article, we'll guide you through the installation process for MariaDB on Linux, Windows, and macOS. Let's get started!

Installing MariaDB on Linux

We'll cover the installation process for the most popular Linux distributions: Ubuntu, Debian, CentOS, and Fedora.

Ubuntu and Debian

  1. Update Package Index
    Open a terminal and run the following command to update your package index.

    sudo apt update
    
  2. Install MariaDB Server
    Install the MariaDB server package using the command below:

    sudo apt install mariadb-server
    
  3. Secure the Installation
    After installation, it's important to run a security script that comes with MariaDB. This will help you set up options that enhance your installation's security.

    sudo mysql_secure_installation
    

    You'll be prompted to set a root password, remove anonymous users, disallow root login remotely, and remove the test database. Go through each prompt and provide your preferred options.

  4. Start MariaDB
    You can start the MariaDB service with:

    sudo systemctl start mariadb
    
  5. Enable at Boot
    To ensure that MariaDB starts automatically at boot, use the command:

    sudo systemctl enable mariadb
    
  6. Verify the Installation
    To confirm that MariaDB is installed correctly, connect to the database server:

    sudo mysql -u root -p
    

    If you entered your password correctly and connected successfully, congratulations! MariaDB is now installed on your Linux machine.

CentOS

  1. Install the MariaDB Repository
    First, install the EPEL repository before installing MariaDB.

    sudo yum install epel-release
    
  2. Install MariaDB Server
    Now, install MariaDB using the following command:

    sudo yum install mariadb-server
    
  3. Start and Enable the Service
    Start the MariaDB service and enable it to start on boot:

    sudo systemctl start mariadb
    sudo systemctl enable mariadb
    
  4. Secure the Installation
    Similar to Ubuntu, run the security script:

    sudo mysql_secure_installation
    

    Follow the prompts to secure your installation.

  5. Verify the Installation
    To check your installation, log in to MariaDB:

    mysql -u root -p
    

Fedora

  1. Install MariaDB
    Open a terminal and run:

    sudo dnf install mariadb-server
    
  2. Start the MariaDB Service
    Enable and start the MariaDB service:

    sudo systemctl start mariadb
    sudo systemctl enable mariadb
    
  3. Secure the Installation
    To secure your installation, execute:

    sudo mysql_secure_installation
    
  4. Verify the Installation
    Finally, log into MariaDB:

    mysql -u root -p
    

Installing MariaDB on Windows

To install MariaDB on Windows, follow these steps:

  1. Download the Installer
    Visit the MariaDB download page and select the appropriate version of the Windows installer.

  2. Run the Installer
    Once downloaded, double-click the installer to start the installation process.

  3. Follow the Installation Wizard

    • Accept the license agreement.
    • Choose the installation type (Typical is recommended for most users).
    • If prompted, you can choose to install a sample database.
    • Specify the root password that you will use later to access the database.
    • Choose the port where MariaDB will run (the default is usually 3306).
  4. Finish the Installation
    Once you’ve gone through the wizard, click “Finish” to complete the installation. The installer will also set up MariaDB as a Windows service by default, which means it will start automatically when your computer boots.

  5. Verify the Installation
    Open the command prompt and execute:

    mysql -u root -p
    

    Enter your password to log in. If you see the MariaDB prompt, the installation was successful!

Installing MariaDB on macOS

For macOS users, the easiest way to install MariaDB is through Homebrew.

  1. Install Homebrew (if not already installed)
    Open the terminal and install Homebrew using the following command:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  2. Update Homebrew
    Make sure your Homebrew is up-to-date:

    brew update
    
  3. Install MariaDB
    Now, install MariaDB with the command:

    brew install mariadb
    
  4. Start MariaDB
    Start the MariaDB server using the following command:

    brew services start mariadb
    
  5. Secure the Installation
    Run the security script:

    mysql_secure_installation
    

    Follow the prompts to secure your installation.

  6. Verify the Installation
    Connect to your MariaDB server:

    mysql -u root -p
    

    Enter your password, and if you successfully connect, MariaDB is installed and ready to use!

Conclusion

After following the steps outlined for your respective operating system, you should now have MariaDB installed and running seamlessly. Don't forget to secure your installation and explore the myriad of configurations and options that MariaDB offers to customize your database environment. Enjoy building with MariaDB!