In this blog, we’ll show you how to install MariaDB 10.4 on Ubuntu 22.04 servers.
We ran into some issues with MariaDB 10.4 installations on Ubuntu 22.04 servers. The MariaDB team stopped producing the deb package of MariaDB 10.04 for Ubuntu 22.04 servers. In Cleavr, we always want our users to have a better experience, so we planned to implement an alternate installation to either downgrade the versions of some security-related packages or a straightforward installation which takes almost 25-30 minutes 😬.
However, We didn’t want to compromise installations nor to take so much of users time. So we decided not to support MariaDB 10.4 moving forward.
However, if you still need to install MariaDB 10.4 on your Ubuntu 22.04 server, we’ll show you how you can do this using [MariaDB Binary Tarballs](https://mariadb.com/kb/en/installing-mariadb-binary-tarballs/. If you want to download any other unsupported versions of MariaDB, you can still follow this blog.
Here’s a summary of what we will be doing throughout this blog:
As a first step, SSH into the server as a root user and add create a
mysql user so that we can install MariaDB under the user and group
Run the following command to create a new group and user called
groupadd mysql useradd -g mysql
Now, we'll change our directory to
cd /usr/local. This is the default directory where MariaDB is installed. So we’ll be
downloading the binary tarballs in this directory. To download the tar file run the following
If you’re following this blog and intending to download 10.3, or any other versions, just replace the version number and run the command.
For example, if you want to install MariaDB 10.3.38 the command will be:
The download may take around 25-30 minutes to complete depending on your internet connection.
Once the file is downloaded, extract the files using the
tar -zxvpf mariadb-10.4.28-linux-systemd-x86_64.tar.gz
Let's rename the extracted file to mariadb10.4 for convenience.
mv mariadb-10.4.28-linux-systemd-x86_64 mariadb10.4
Now let's create a symlink of the
mariadb10.4 and point to
/usr/local/mysql is the default location for MariaDB though it may
be different in some platforms. Creating the symlink will also help you if you decide to change the MariaDB version.
ln -s /usr/local/mariadb10.4 mysql
We need to initialize the MariaDB data directory and create the system tables. Run the following command to change the directory to
mysql, initialize the MariaDB data directory, and create the system tables:
cd mysql && ./scripts/mysql_install_db --user=mysql
We need to fix the ownership of our new files. Run the following
chown -R root . chown -R mysql data
We’ll now export the path where mysql exists by updating the
.bashrc file. We’ll then be able to test the connection by invoking clients
Run the following command to add the export path to
echo "export PATH=$PATH:/usr/local/mysql/bin/" >> ~/.bashrc
source ~/.bashrc so that you don’t have to restart your shell to reflect the new changes.
You can configure mysqld (the MariaDB server) by copying the
mysql.server file to the right place.
cp support-files/mysql.server /etc/init.d/mysql.server
Next, we need to copy the
mariadb.service file to its proper place.
cp support-files/systemd/mariadb.service /usr/lib/systemd/system/mariadb.service
By default the
/usr/ directory is write protected by systemd, so let's make our data directory writable.
cat > /etc/systemd/system/mariadb.service.d/datadir.conf <<EOF [Service] ReadWritePaths=/usr/local/mysql/data EOF
Once you run the above command reload the systemd manager configuration by running
systemctl daemon-reload command.
Finally, we can start the MariaDB service using:
systemctl start mariadb.service
Let's verify our installation by checking the status of MariaDB by running:
systemctl status mariadb
If you want MariaDB to start automatically when you boot up your device enable the service by running:
systemctl enable mariadb.service
That’s all for this blog. I hope it helps you with MariaDB 10.4 installation on your Ubuntu 22.04 server.
Sign up for a 5-day free trial of Cleavr Pro. No credit card required until you decide to subscribe.Sign up for free