How To Reset Forgotten MariaDB/MySQL Root Password on Ubuntu and CentOS

This article will come in handy if you have forgotten your MariaDB root password. If you are setting up a MySQL or MariaDB database server for the first time, chances are you will be running mysql_secure_installation soon afterward to implement basic security settings.