If after a major upgrade (typically to a new LTS release) your maridb local server doesn’t work any more, it could be a problem of AppArmor settings.
To solve it you can try with
sudo nano /etc/apparmor.d/tunables/alias
and then, add the end of that file
alias /var/lib/mysql/ -> /your/mysql-data/path/,
and then
sudo systemctl reload apparmor
and
sudo systemctl start mariadb