What's the best way to migrate from mariadb to mysql on ubuntu 18.04
Confluence officially supports a number of different database systems, including MySQL 5.6 and 5.7, but not 8.0, and also does not officially support MariaDB. 

If you want to migrate an existing Confluence database running on MariaDB to MySQL, then mysqldump is a guaranteed route to success. Just dump the existing database to an SQL file, and then import this into MySQL using e.g. the mysql command-line client. This could be slow if it's a big database. 

FWIW, the company I work for has a major Confluence installation on MariaDB 5.5, which is the default in RHEL7/CentOS7, and this has been running for several years with no known issues.