MariaDB is an open-source relational database management system, commonly used as an alternative for MySQL as the database portion of the popular LAMP (Linux, Apache, MySQL, PHP/Python/Perl) stack. It is intended to be a drop-in replacement for MySQL.
To follow this tutorial, you will need a server running Ubuntu 20.04. This server should have a non-root administrative user and a firewall configured with UFW. Set this up by following our initial server setup guide for Ubuntu 20.04.
These commands will install and start MariaDB, but will not prompt you to set a password or make any other configuration changes. Because the default configuration leaves your installation of MariaDB insecure, we will use a script that the mariadb-server package provides to restrict access to the server and remove unused accounts.
For new MariaDB installations, the next step is to run the included security script. This script changes some of the less secure default options for things like remote root logins and sample users.
From there, you can press Y and then ENTER to accept the defaults for all the subsequent questions. This will remove some anonymous users and the test database, disable remote root logins, and load these new rules so that MariaDB immediately implements the changes you have made.
On Ubuntu systems running MariaDB 10.3, the root MariaDB user is set to authenticate using the unix_socket plugin by default rather than with a password. This allows for some greater security and usability in many cases, but it can also complicate things when you need to allow an external program (e.g., phpMyAdmin) administrative rights.
To this end, we will create a new account called admin with the same capabilities as the root account, but configured for password authentication. Open up the MariaDB prompt from your terminal:
For an additional check, you can try connecting to the database using the mysqladmin tool, which is a client that lets you run administrative commands. For example, this command says to connect to MariaDB as root using the Unix socket and return the version:
These commands will install MariaDB, but will not prompt you to set a password or make any other configuration changes. Because the default configuration leaves your installation of MariaDB insecure, you will use a script that the mariadb-server package provides to restrict access to the server and remove unused accounts.
On Ubuntu systems running MariaDB 10.5, the root MariaDB user is set to authenticate using the unix_socket plugin by default rather than with a password. This allows for some greater security and usability in many cases, but it can also complicate things when you need to allow an external program (e.g., phpMyAdmin) administrative rights.
For an additional check, you can try connecting to the database using the mysqladmin tool, which is a client that allows you to run administrative commands. For example, this command says to connect to MariaDB as root using the Unix socket and return the version:
On Debian, Ubuntu, and other similar Linux distributions, it is highly recommended to install the relevant .deb packages from MariaDB'srepository using apt, aptitude, Ubuntu Software Center, Synaptic Package Manager, or another packagemanager.
MariaDB Corporation provides a MariaDB Package Repository for several Linux distributions that use apt to manage packages. This repository contains software packages related to MariaDB Server, including the server itself, clients and utilities, client libraries, plugins, and Mariabackup. The MariaDB Package Repository setup script automatically configures your system to install packages from the MariaDB Package Repository.
The MariaDB Foundation provides a MariaDB repository for several Linux distributions that use apt-get to manage packages. This repository contains software packages related to MariaDB Server, including the server itself, clients and utilities, client libraries, plugins, and Mariabackup. The MariaDB Repository Configuration Tool can easily generate the appropriate commands to add the repository for your distribution.
For example, if you wanted to use the repository to install MariaDB 10.3 on Ubuntu 18.04 LTS (Bionic), then you could create the MariaDB.list file in /etc/apt/sources.list.d/ with the following contents to add the MariaDB apt repository:
Once the Software Sources window is open, go to the Other Software tab, and click the Add button. At that point, you can input the repository information provided by the MariaDB Repository Configuration Tool.
If you wish to pin the apt repository to a specific minor release, or if you would like to downgrade to a specific minor release, then you can create a apt repository with the URL hard-coded to that specific minor release.
Archives are only of the distros and architectures supported at the time of release. For example MariaDB 10.0.38 is exists for Ubuntu precise, trusty, xenial, wily, and yakkety obtained looking in -10.0.38/repo/ubuntu/dists.
For example, if you wanted to pin your repository to MariaDB 10.5.9 on Ubuntu 20.04 LTS (Focal), then you would have to first remove any existing MariaDB repository source list file from /etc/apt/sources.list.d/. And then you could use the following commands to add the MariaDB apt-get repository:
If you configured apt to install from MariaDB Corporation's MariaDB Package Repository by using the MariaDB Package Repository setup script, then you can update the major release that the repository uses by running the script again.
If you configured apt to install from MariaDB Foundation's MariaDB Repository by using the MariaDB Repository Configuration Tool, then you can update the major release in various ways, depending on how you originally added the repository.
And then, you can remove the repository for the old version by executing the add-apt-repository command and providing the --remove option. For example, if you wanted to remove a MariaDB 10.2 repository, then you could do so by executing something like the following:
After that, you can add the repository for the new version with the add-apt-repository command. For example, if you wanted to use the repository to install MariaDB 10.3 on Ubuntu 18.04 LTS (Bionic), then you could use the following commands to add the MariaDB apt repository:
If you added the apt repository by creating a source list file in /etc/apt/sources.list.d/, then you can update the major release that the repository uses by updating the source list file in-place. For example, if you wanted to change the repository from MariaDB 10.2 to MariaDB 10.3, and if the source list file was at /etc/apt/sources.list.d/MariaDB.list, then you could execute the following:
Before MariaDB can be installed, you also have to import the GPG public key that is used to verify the digital signatures of the packages in our repositories. This allows the apt utility to verify the integrity of the packages that it installs.
After the apt repository is configured, you can install MariaDB by executing the apt-get command. The specific command that you would use would depend on which specific packages that you want to install.
MariaDB Galera Cluster also has a separate package that can be installed on arbitrator nodes. In MariaDB 10.4 and later, the package is called galera-arbitrator-4 In MariaDB 10.3 and before, the package is called galera-arbitrator-3. This package should be installed on whatever node you want to serve as the arbitrator. It can either run on a separate server that is not acting as a cluster node, which is the recommended configuration, or it can run on a server that is also acting as an existing cluster node.
However, when installing an older version of a package, if apt-get has to install dependencies, then it will automatically choose to install the latest versions of those packages. To ensure that all MariaDB packages are on the same version in this scenario, it is necessary to specify them all. Therefore, to install MariaDB 10.3.14 from this apt repository, we would do the following:
I've inspected a bit my situation, and indeed I have not MariaDB already installed, and indeed it's not running as root. But, I have something called "akonadi" that is running as my dedicated low-privileged desktop username and it seems it's running its dedicated MariaDB for some reasons.
Yes, it seems that in Debian bookworm KDE (and maybe other distributions like Ubuntu KDE etc.) there is this executable called akonadi that runs as default with the package akonadi-backend-mysql that requires its own MariaDB that - in theory - is completely separated from mariadb-server but in practice it's not.
d3342ee215