How to reset root or any user's password in MySQL

Submitted by gvso on Tue, 02/28/2017 - 23:48

This week I run into the following issue when trying to connect to my new MySQL server installation

mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost'

This was somehow strange since it was a local installation, and I did not remember entering a default password for the root user. I was able to solve this issue by following @user2977819's comment. The solution is basically resetting the root user's password.