Cannot reset MySQL default root password after initial installation
Restart the service without authentication

Ubuntu/Debian

service mysql stop
service mysql start --skip-grant-tables --skip-networking


Other sysv

If you're on a sysv Linux use this

/etc/init.d/mysqld stop
/etc/init.d/mysqld start --skip-grant-tables --skip-networking &amp;


Resetting

Then you need to login as root

mysql -u root -p


Then when logged in run

FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';


Difference between other guides

There are a lot of "guides" on this, for clarity,


Some guides use the older SET PASSWORD syntax, that's pre 5-7.6, don't use that anymore.
Some guides just don't use --skip-networking, that's unsafe.
Some guides don't connect with the -u root that's more error-prone.