Solution :
You need to just login to mysql
mysql -u root -p
After that execute below command:
flush-privileges;
If this doesn't work then execute below command:
FLUSH PRIVILEGES;
OR
You can make this done just by using the below steps.
[root@backups1 mysql5.7]# bin/mysqld_safe --skip-grant-tables --user=mysql
Need to connect to your mysql without the password and execute below commands:
mysql> flush privileges;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '';
mysql> flush privileges;
Now just switch to the normal mode of mysql then connect without password.
I hope this will work for you.