Need procedure for installing MySQL instead of MariaDB

To save head-scratching and hair-pulling of anyone intending to do this, here’s how it goes:

According to MySQL :: MySQL 8.0 Reference Manual :: 2.10.4 Securing the Initial MySQL Account :
Installation using RPM packages generates an initial random password, which is written to the server error log.
But no, that’s not correct. In the log the password is not output, and instead there are messages that encourage to run a command to change the root password, which does not run, of course, because the root password is not known… Ugh!

The solution is to reset the root password right after the installation by performing the following dance (as detailed at MySQL :: MySQL 8.0 Reference Manual :: B.3.3.2 How to Reset the Root Password):

(as mentioned in the OP, remove MariaDB and disable the mysql builtin repo)

yum install mysql-community-server -y
virtualmin-config-system -i MySQL
service mysqld start
sleep 3
service mysqld stop

echo "ALTER USER 'root'@'localhost' IDENTIFIED BY 'MY-ROOT-PASSWORD';">/tmp/sql-init
chmod 777 /tmp/sql-init

mysqld --user=mysql --init-file=/tmp/sql-init &
kill `cat /var/run/mysqld/mysqld.pid`

rm /tmp/sql-init
service mysqld start
ln -s /etc/systemd/system/multi-user.target.wants/mysqld.service /etc/systemd/system/mariadb.service
mysql_secure_installation

Answer: n, y, y, y, y

Now the root’s password must be set in the Webmin MySQL module.

Warning: The password gets stored in the history file if you’re working with bash, so logout then login again and execute this:
rm -f /root/.bash_history