why not? have you tried? Just to prove that it is possible:
hans@cac3:~$ cat /etc/*release* | head -4
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.2 LTS"
hans@cac3:~$ mkdir test
hans@cac3:~$ cd test
hans@cac3:~/test$ mkdir mysql
hans@cac3:~/test$ cd mysql/
hans@cac3:~/test/mysql$ mkdir datadir
hans@cac3:~/test/mysql$ wget 'https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz';
--2023-07-23 16:03:53-- https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz
Resolving dev.mysql.com (dev.mysql.com)... 184.86.41.128, 2600:140a:0:69b::2e31, 2600:140a:0:682::2e31
Connecting to dev.mysql.com (dev.mysql.com)|184.86.41.128|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz [following]
--2023-07-23 16:03:53-- https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz
Resolving cdn.mysql.com (cdn.mysql.com)... 23.216.84.226
Connecting to cdn.mysql.com (cdn.mysql.com)|23.216.84.226|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 610315332 (582M) [text/plain]
Saving to: ‘mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz’
mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz 100%[==================================================================================================================================================================>] 582.04M 75.4MB/s in 8.8s
2023-07-23 16:04:02 (66.4 MB/s) - ‘mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz’ saved [610315332/610315332]
hans@cac3:~/test/mysql$ tar xf mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz
hans@cac3:~/test/mysql$ cd mysql-8.0.32-linux-glibc2.12-x86_64/
bin docs include lib LICENSE man README share support-files
hans@cac3:~/test/mysql/mysql-8.0.32-linux-glibc2.12-x86_64$ nano my.cnf
[mysqld]
socket = /home/hans/test/mysql/mysqld.sock
skip_networking = 1
max_connections = 20
disable-log-bin = 1
skip-name-resolve = 1
performance-schema = 0
mysqlx = 0
max_allowed_packet = 50M
innodb_buffer_pool_size = 8M
innodb_buffer_pool_instances = 1
datadir = /home/hans/test/mysql/datadir
hans@cac3:~/test/mysql/mysql-8.0.32-linux-glibc2.12-x86_64$ ./bin/mysqld --defaults-file=./my.cnf --initialize-insecure
2023-07-23T16:07:40.884830Z 0 [System] [MY-013169] [Server] /home/hans/test/mysql/mysql-8.0.32-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.32) initializing of server in progress as process 657947
2023-07-23T16:07:40.900041Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-07-23T16:07:44.047090Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-07-23T16:07:49.932629Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
hans@cac3:~/test/mysql/mysql-8.0.32-linux-glibc2.12-x86_64$ ./bin/mysqld --defaults-file=./my.cnf &
[1] 658166
hans@cac3:~/test/mysql/mysql-8.0.32-linux-glibc2.12-x86_64$ 2023-07-23T16:08:35.314238Z 0 [System] [MY-010116] [Server] /home/hans/test/mysql/mysql-8.0.32-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.32) starting as process 658166
2023-07-23T16:08:35.320343Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-07-23T16:08:35.840163Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-07-23T16:08:37.344209Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-07-23T16:08:37.344267Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-07-23T16:08:37.428006Z 0 [System] [MY-010931] [Server] /home/hans/test/mysql/mysql-8.0.32-linux-glibc2.12-x86_64/bin/mysqld: ready for connections. Version: '8.0.32' socket: '/home/hans/test/mysql/mysqld.sock' port: 0 MySQL Community Server - GPL.
hans@cac3:~/test/mysql/mysql-8.0.32-linux-glibc2.12-x86_64$
50% success! now we have MySQL running in the background! now to get MariaDB to run in the background as well:
hans@cac3:~/test/mysql/mysql-8.0.32-linux-glibc2.12-x86_64$ cd ~/test/
mysql
hans@cac3:~/test$ mkdir mariadb
hans@cac3:~/test$ cd mariadb/
hans@cac3:~/test/mariadb$ mkdir datadir
hans@cac3:~/test/mariadb$ wget 'https://archive.mariadb.org/mariadb-11.0.2/bintar-linux-systemd-x86_64/mariadb-11.0.2-linux-systemd-x86_64.tar.gz'
--2023-07-23 16:11:30-- https://archive.mariadb.org/mariadb-11.0.2/bintar-linux-systemd-x86_64/mariadb-11.0.2-linux-systemd-x86_64.tar.gz
Resolving archive.mariadb.org (archive.mariadb.org)... 138.201.152.105, 2a01:4f8:c17:cad6::1
Connecting to archive.mariadb.org (archive.mariadb.org)|138.201.152.105|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 346184990 (330M) [application/octet-stream]
Saving to: ‘mariadb-11.0.2-linux-systemd-x86_64.tar.gz’
mariadb-11.0.2-linux-systemd-x86_64.tar.gz 100%[==================================================================================================================================================================>] 330.15M 6.47MB/s in 36s
2023-07-23 16:12:06 (9.25 MB/s) - ‘mariadb-11.0.2-linux-systemd-x86_64.tar.gz’ saved [346184990/346184990]
hans@cac3:~/test/mariadb$ tar xf mariadb-11.0.2-linux-systemd-x86_64.tar.gz
hans@cac3:~/test/mariadb$ cd mariadb-11.0.2-linux-systemd-x86_64/
bin COPYING CREDITS docs include INSTALL-BINARY lib man mysql-test README.md README-wsrep scripts share sql-bench support-files THIRDPARTY
hans@cac3:~/test/mariadb/mariadb-11.0.2-linux-systemd-x86_64$ nano my.cnf
[mysqld]
socket = /home/hans/test/mariadb/mariadbd.sock
skip_networking = 1
max_connections = 20
disable-log-bin = 1
skip-name-resolve = 1
performance-schema = 0
max_allowed_packet = 50M
innodb_buffer_pool_size = 8M
innodb_buffer_pool_instances = 1
datadir = /home/hans/test/mariadb/datadir
hans@cac3:~/test/mariadb/mariadb-11.0.2-linux-systemd-x86_64$ ./scripts/mariadb-install-db --auth-root-authentication-method=normal --defaults-file=./my.cnf
Installing MariaDB/MySQL system tables in '/home/hans/test/mariadb/datadir' ...
2023-07-23 16:29:05 0 [Warning] 'innodb-buffer-pool-instances' was removed. It does nothing now and exists only for compatibility with old my.cnf files.
OK
To start mariadbd at boot time you have to copy
support-files/mariadb.service to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following command:
'./bin/mariadb-secure-installation'
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the MariaDB Knowledgebase at https://mariadb.com/kb
You can start the MariaDB daemon with:
cd '.' ; ./bin/mariadb-safe --datadir='/home/hans/test/mariadb/datadir'
You can test the MariaDB daemon with mariadb-test-run.pl
cd './mysql-test' ; perl mariadb-test-run.pl
Please report any problems at https://mariadb.org/jira
The latest information about MariaDB is available at https://mariadb.org/.
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
hans@cac3:~/test/mariadb/mariadb-11.0.2-linux-systemd-x86_64$ ./bin/mariadbd --defaults-file=./my.cnf &
[2] 661169
hans@cac3:~/test/mariadb/mariadb-11.0.2-linux-systemd-x86_64$ 2023-07-23 16:30:00 0 [Note] Starting MariaDB 11.0.2-MariaDB source revision 0005f2f06c8e1aea4915887decad67885108a929 as process 661169
2023-07-23 16:30:00 0 [Note] InnoDB: Compressed tables use zlib 1.2.13
2023-07-23 16:30:00 0 [Note] InnoDB: Number of transaction pools: 1
2023-07-23 16:30:00 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2023-07-23 16:30:00 0 [Note] InnoDB: Using Linux native AIO
2023-07-23 16:30:00 0 [Note] InnoDB: Initializing buffer pool, total size = 8.000MiB, chunk size = 1.000MiB
2023-07-23 16:30:00 0 [Note] InnoDB: Completed initialization of buffer pool
2023-07-23 16:30:00 0 [Note] InnoDB: File system buffers for log disabled (block size=512 bytes)
2023-07-23 16:30:00 0 [Note] InnoDB: Opened 3 undo tablespaces
2023-07-23 16:30:00 0 [Note] InnoDB: 128 rollback segments in 3 undo tablespaces are active.
2023-07-23 16:30:00 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
2023-07-23 16:30:00 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
2023-07-23 16:30:00 0 [Note] InnoDB: log sequence number 47139; transaction id 14
2023-07-23 16:30:00 0 [Note] Plugin 'FEEDBACK' is disabled.
2023-07-23 16:30:00 0 [Note] Plugin 'wsrep-provider' is disabled.
2023-07-23 16:30:00 0 [Note] InnoDB: Loading buffer pool(s) from /home/hans/test/mariadb/datadir/ib_buffer_pool
2023-07-23 16:30:00 0 [Warning] 'innodb-buffer-pool-instances' was removed. It does nothing now and exists only for compatibility with old my.cnf files.
2023-07-23 16:30:00 0 [Note] InnoDB: Buffer pool(s) load completed at 230723 16:30:00
2023-07-23 16:30:00 0 [Warning] 'user' entry 'root@cac3.loltek.net' ignored in --skip-name-resolve mode.
2023-07-23 16:30:00 0 [Warning] 'user' entry '@cac3.loltek.net' ignored in --skip-name-resolve mode.
2023-07-23 16:30:00 0 [Warning] 'proxies_priv' entry '@% root@cac3.loltek.net' ignored in --skip-name-resolve mode.
2023-07-23 16:30:00 0 [Note] ./bin/mariadbd: ready for connections.
Version: '11.0.2-MariaDB' socket: '/home/hans/test/mariadb/mariadbd.sock' port: 0 MariaDB Server
Success! now we have both MySQL and MariaDB running side-by-side, with MySQL listening on /home/hans/test/mysql/mysqld.sock
and MariaDB listening on /home/hans/test/mariadb/mariadbd.sock
, and to prove that they both work, we run this little php script:
hans@cac3:~/test/mariadb/mariadb-11.0.2-linux-systemd-x86_64$ nano test.php
<?php
declare(strict_types=1);
$mysql = new PDO('mysql:unix_socket=/home/hans/test/mysql/mysqld.sock', 'root', '', array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
));
$mariadb = new PDO('mysql:unix_socket=/home/hans/test/mariadb/mariadbd.sock', 'root', '', array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
));
var_dump($mysql->query("SELECT VERSION()")->fetchAll());
var_dump($mariadb->query("SELECT VERSION()")->fetchAll());
and the final proof:
hans@cac3:~/test/mariadb/mariadb-11.0.2-linux-systemd-x86_64$ php test.php
array(1) {
[0]=>
array(2) {
["VERSION()"]=>
string(6) "8.0.32"
[0]=>
string(6) "8.0.32"
}
}
array(1) {
[0]=>
array(2) {
["VERSION()"]=>
string(14) "11.0.2-MariaDB"
[0]=>
string(14) "11.0.2-MariaDB"
}
}
-
TL;DR: MySQL and MariaDB can run side-by-side, as long as they use separate data-dirs and separate ports
-
(in this example, i didn’t use any ports at all, but unix sockets instead of tcp ports, because it makes authentication easier)