In case if you have forgotten your root password used in MySQL, don’t worry, here is a simple and easiest solution for you. Btw, I’m testing this on my Ubuntu machine. I am not sure if this method will work on other linux distribution.

Firstly you need to stop mysql service running at the backround. Open your terminal then type following command

Start the mysqld demon process using the --skip-grant-tables  option with this command

Change root password using this command ( change ‘yournewpassword’ to your desired secure password )

Now your root password already set. You need to restart the mysql service with this command.