Mysql - server

Reset root password

$ service mysqld stop
$ mysqld_safe --skip-grant-tables &
$ mysql -u root
> use mysql;
> UPDATE user SET password=PASSWORD("YOUR NEW PASSWORD HERE") WHERE User='root';
> flush privileges;
> quit
$ service mysqld stop
$ service mysqld start
$ mysql -u root -p

Reset root password on mariadb 10.4+:

# systemctl stop mysqld
# mysqld_safe --skip-grant-tables &
# mysql -u root mysql

FLUSH PRIVILEGES;
ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD('my secret password');
FLUSH PRIVILEGES;
quit