In Linux Debian/Ubuntu an extra user debian-sys-maint which also has all the access rights is used for maintenance. It can also be used to reset users passwords especially the root password when lost. Here are some tips regarding resetting them.
Resetting the ‘root’ password
mysqladmin -u root -p password "MyNewPass"
mysql -u debian-sys-maint -p
update mysql.user set Password=password('MyNewPass') where User='root';
Resetting/creating the user and giving it all the access rights.
mysql -u root -p
create user 'debian-sys-maint'@'localhost' identified by 'UserPassword';
grant all privileges on *.* to 'debian-sys-maint'@'localhost'
SETTING root password for the first time.
In the case where after the initial installation of MySQL/MariaDB the request for root password was not initiated, you can set the root password as shown above. BUT if that doesn’t work then we probably have a case of plugin incompatibility. In this case it is recommended to use the following commands:
Login as root without password in MySQL/MariaDB server using the client program (mysql) and use the following commands:
UPDATE mysql.user SET authentication_string = PASSWORD('NEWPASSWORD'), plugin = 'mysql_native_password' WHERE User = 'root' AND Host = 'localhost';