1

Something I've seen stump users (including myself) is that Apt won't allow both MySQL and MariaDB to be installed. For instance, here's a nearly 3-year-old AskUbuntu question on the topic, still unanswered.

As a concrete description of the problem, consider Ubuntu 22.04. If I have MySQL installed using Apt, and I then attempt to install the MariaDB package, Apt will demand the removal of MySQL:

# MySQL 8.0 is installed:
$ apt-cache policy mysql-server-8.0 
mysql-server-8.0:
  Installed: 8.0.30-0ubuntu0.22.04.1
  Candidate: 8.0.30-0ubuntu0.22.04.1
  ...

MariaDB 10.6 is not installed:

$ apt-cache policy mariadb-server-10.6 mariadb-server-10.6: Installed: (none) Candidate: 1:10.6.7-2ubuntu1.1 ...

Attempt to install MariaDB 10.6:

$ sudo apt install mariadb-server-10.6 ... The following additional packages will be installed: galera-4 gawk libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libsigsegv2 libterm-readkey-perl mariadb-client-10.6 mariadb-client-core-10.6 mariadb-server-core-10.6 ...

MySQL packages are removed:

The following packages will be REMOVED: mysql-client-8.0 mysql-client-core-8.0 mysql-server mysql-server-8.0 mysql-server-core-8.0 ...

I've never heard anyone give a good reason for this. MySQL and MariaDB are quite similar, but that doesn't automatically preclude them from co-existing. In fact, multiple versions of MySQL itself can co-exist on the same machine, as explained by MySQL. And as explained by MariaDB, there's no reason one of those multiple versions can't be an instance of MariaDB.

So if there's no fundamental reason I can't have MySQL and MariaDB installed at the same time, why does Apt insist on treating these as mutually exclusive?

  • @user535733 That seems like a good thread to follow. Do you know an example of one of the overlapping files off the top of your head? – Darien Marks Sep 10 '22 at 18:16
  • 1
    everything in /var/lib/mysql and /etc/my.conf. Mariadb is a drop in replacement so for all intent and purpose you need to see MariaDB as another MySQL version. – Rinzwind Sep 10 '22 at 18:22
  • You should consider containers if you intend to run multiple databases on a single installation. – Artur Meinild Sep 10 '22 at 18:43

1 Answers1

5

You can have multiple MySQLs but only ONE installed using apt. For installing through apt MariaDB is the same as a MySQL install: MariaDB is a drop-in replacement and the 2 use the same library names and files (both in /var/lib/mysql and /etc/mysql/my.conf). Maybe in the future this might change.

But like you can install more versions MySQL in for instance /opt and even have those run at the same time using another port you can also add more than 1 MariaDB to all those MySQL installs in /opt and using its own port. Or install more than one using the same port having only 1 active at a time.

sotirov
  • 3,169
Rinzwind
  • 299,756
  • I don't see why using the same libraries is an obstacle. That's what libraries are for, in fact. To abstract the problem, consider packages mysql and mariadb, representing the obvious programs, and a third package sql-libs, representing the shared libraries. Once mysql and its dependency sql-libs is installed, there's no reason another package mariadb can't be installed simultaneously to use the same sql-libs. – Darien Marks Sep 10 '22 at 18:12
  • 3
    @DarienMarks They are "the same" libraries in sense of file names/paths, but they are different in sense of the file contents. So they are in fact conflicting libraries. MySQL and MariaDB cannot use a common set of libraries as you suggest, because both packages contain two different versions of "the same" (in sense of names) libraries. They are just designed so. So how to decide which version to use? If you use version for MySQL, it may work improperly with MariaDB and vice versa. – raj Sep 10 '22 at 18:33
  • Hmm I changed it to "library names" :) – Rinzwind Sep 10 '22 at 18:34