MariaDB is just Mysql but it's actually maintained.

$ doas pkg_add mariadb-server php-mysqli

RTFM and adjust accordingly

less /usr/local/share/doc/pkg-readmes/mariadb-server

Install and enable services, I like to choose socket auth for root

$ doas mysql_install_db
$ doas rcctl enable mysqld
$ doas rcctl start mysqld
$ doas mysql_secure_installation

change the socket location so that it's inside of our httpd chroot

$ doas install -d -m 0711 -o _mysql -g _mysql /var/www/var/run/mysql

and edit /etc/my.cnf to use this modified socket location. Append:

[client-server]
socket = /var/www/var/run/mysql/mysql.sock

And test mysql

$ doas rcctl restart mydqld
$ doas su
# echo "show databases;" | mysql -uroot

Add user, create tables

# echo "CREATE USER IF NOT EXISTS 'www'@'127.0.0.1; IDENTIFIED BY 'YouReallyShouldBePUttingThisInYourPhp.ini';" | mysql
# echo "CREATE DATABASE www;" | mysql
# echo "GRANT ALL PRIVILEGES ON www.* TO 'www'@'127.0.0.1';" | mysql
# echo "FLUSH PRIVILEGES;" | mysql
# echo 'CREATE TABLE www.testing (id int not null auto_increment primary key, data text not null);' | mysql
# echo 'INSERT INTO www.testing (data) VALUES ("foo");' | mysql
# echo 'INSERT INTO www.testing (data) VALUES ("bar");' | mysql
# echo 'INSERT INTO www.testing (data) VALUES ("baz");' | mysql

enable mysqli in /etc/php-8.0.ini, find and uncomment the line that says:

;     extension=mysqli

see if everythign works in php

<?php
$sqlhost = "127.0.0.1";
$user = "www";
$pass = "pass";
$table = "www";
$db = new mysqli($sqlhost, $user, $pass, $table);

if($db->connect_error){
	die("con failed" . $db->connect_error);
}

$res = $db->query("SELECT * FROM www.testing;");

foreach($res as $row){
	echo "id = ". $row['id'] . " | data = " . $row['data'] . "<br>";
}
?>