The error received when I try to reconfigure the mysql is shown because of the missing "libdbd-mysql-perl" package.
If I manualy install that package and the dependency "libmariadbclient18" it will auto remove the "libmariadb3, mariadb-client-10.2, mariadb-client-core-10.2". To manualy install mariadb, I have to install about 12 packages, the dependencies of some of the packages depend on 10.1, so I ended up in a vicious circle in which I don't know how to get out, that's why I asked if there is a way to clean install all the requirements regarding mysql? all the rest of the services work just fine.
For the time being I just give up on reconfiguring the server as now is not used anymore, migrated on another hosting.