did you check if your apache config “points” to the new php version?
debian 9 has “normally” php7.0 installed. debian 10 moved to php7.3. afaik.
google knows about this problem. e.g.
mysql: which mysql
or locate mysql
will tell you if and where to find file named mysql. apt-cache policy mysql-server
and/or apt-cache policy mariadb-server
will tell you if and which version of mariadb/mysql is installed.
if you removed mysql normally the database is not removed and should be in /var/lib/mysql
.
make a backup of all this files in this folder. plus /etc/mysql plus /var/nextcloud.