How to change the MySQL root password??

First of all we have to do something so that we can enter mysql without password.
We can do that by skipping grant tables, for doing that we have to do the following:
1. Go to : C:\Program Files\MySQL\MySQL Server 5.7\bin directory
Open a command prompt and go to this directory and check the mysql version installed
Command: mysqld –version

2. Now lets check which services are running and check mysql is running or not:
Command: net start

3. Stop MySQL57 service:
Command: net stop mysql57

Now MySQL is not running in our PC, have to edit one file :
Go to : “C:\ProgramData\MySQL\MySQL Server 5.7” and you will file one named: my.ini
For editing this file, we have to open “notepad” as administrator:

open my.ini file and add the following line and save:
new line: skip-grant-tables

 

Now you can use MySql without any password and change the root password
Command: mysql

Change the password:
Command:
mysql> update mysql.user set authentication_string=password(‘root’) where user=’root’ and host=’localhost’; flush privileges;

Now delete the line we added into my.ini file:

Now Start MySQL service again and use MySql with changed password: