MySQL / MariaDB - Reset root pasword

Méthode 1

sudo /etc/init.d/mysql stop
sudo mysqld_safe --skip-grant-tables &
mysql -uroot
USE mysql; -- UPDATE user SET authentication_string=PASSWORD("mynewpassword") WHERE User='root'; UPDATE USER SET Password=PASSWORD("mynewpassword") WHERE USER='root'; FLUSH PRIVILEGES; QUIT