mysql – Reset the MySQL/MariaDB root password

 

$ mysql –version
$ mysql Ver 15.1 Distrib 10.3.31-MariaDB, for debian-linux-gnu (x86_64) using readline 5.

$ sudo systemctl stop mysql
$ sudo mysqld_safe –skip-grant-tables &
$ mysql -u root

> UPDATE mysql.user SET authentication_string = PASSWORD(‚new_password‚) WHERE User = ‚root‘ AND Host = ‚localhost‘;
> FLUSH PRIVILEGES;

$ sudo systemctl stop mysql
$ sudo systemctl start mysql