How To Install MariaDB on Ubuntu 22.04

MariaDB Installation on Ubuntu 22.04

Default Version of MariaDB in Ubuntu 22.04

As of Ubuntu 22.04, the default version of MariaDB available in the official Ubuntu repositories is typically the latest stable release available at the time of the Ubuntu release. You can check the specific version included in your Ubuntu release by running apt show mariadb-server.

Installing MariaDB

  1. Update Package Index:
    Open a terminal and update your package list:

    sudo apt update

  2. Install MariaDB:
    • To install the default version, use:

      sudo apt install mariadb-server

    • To install a specific version, you need to add the MariaDB repository and select the version:
      • Import the MariaDB GPG key:

        sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'

      • Add the MariaDB repository (replace YOUR_VERSION with the desired version, e.g., 10.5):

        sudo add-apt-repository 'deb [arch=amd64] http://mariadb.mirror.globo.tech/repo/YOUR_VERSION/ubuntu focal main'

      • Update the package index:

        sudo apt update

      • Install MariaDB:

        sudo apt install mariadb-server

  3. Securing MariaDB Installation:
    Run the security script:

    sudo mysql_secure_installation

  4. Verifying Installation:
    Check the status of MariaDB:

    systemctl status mariadb.service

  5. Accessing MariaDB:
    Access the MariaDB shell:

    sudo mysql -u root -p

  6. Configuring MariaDB (Optional):
    Edit the configuration:

    sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

    Restart MariaDB after changes:

    sudo systemctl restart mariadb.service

Tips

  • Regularly update your MariaDB installation.
  • Back up your databases regularly.
  • If you're transitioning from MySQL, familiarize yourself with MariaDB's unique features.