apt error after MariaDB to MySQL change

I have install MariaDB on a Ubuntu 16.04 server. Then installed Virtualmin, that require MySQL, so it removed MariaDB and installed MySQL, this caused apt stop working.

When i run “apt update”, it failed with

Next i run ‘apt-get -f install’ as it said in above error message.

That too failed. The error message is

Preparing to unpack …/mysql-server-5.7_5.7.20-0ubuntu0.16.04.1_amd64.deb …
Aborting downgrade from (at least) 10.0 to 5.7.

This is because MySQL detected MairaDB data files in /var/lib/mysql folder, it can’t use same data files as MariaDB is newer version.

To fix the problem, i renamed the folder

Now running “apt-get -f install” fixed the problem with apt.