For new linux users this could be a daunting task. Let me update this with mysql 8(the latest version available right now is 8.0.12 as on 12-Sep-2018)
- Open "mysqld.cnf" configuration file at "/etc/mysql/mysql.conf.d/".
- Add skip-grant-tables to the next line of [mysql] text and save.
- Restart mysql service as "sudo service mysql restart". Now your mysql is free of any authentication.
- Connect to mysql client(also known as mysql-shell) as mysql -u root -p. There is no password to be keyed in as of now.
- run sql command flush privileges;
- Reset the password now as ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPassword';
- Now let's get back to the normal state; remove that line "skip-grant-tables" from "mysqld.cnf" and restart service.
That's it.