Shut down the computer and enter into recovery mode by pressing command + R + power key simultaneously don’t release the keys until apple logo appears on the desktop , a bar will start loading , let it be completed .Select English language and click on right arrow .
Take cursor on top menu bar , click on Utilities again click on terminal type a command resetpassword and click on enter key on the keyboard .
Select a user ( press forcefully on the trackpad ) to reset the password and options will be shown ( a ) exit ( b) next .
Click on next an option will be shown enter the password for Apple ID , so you have to enter the password of your Apple ID .
Again click on next .
Options will be shown reset password .
New password ……
Verify password …..
Password hint …….
Enter the new password you have thought in the above fields , password hint field is optional .
Again click on next .
Your user account password has been reset . You may reboot and sign in using your new password .
Click on restart , the machine will restart after few minutes ..
You will see various passwords like accountsd want your keychain access and will prompt to enter new passwords and it won’t accept .
Click on cancel , then a new pop - up again cancel , cancel ...
Restart your machine and open Keychain Access via spotlight .
Press command + comma to open its preferences and click on reset my default keychain .
A new keychain will be created in user library > keychain folder and your old keychain will be deactivated .
Now , the most important is you must have 4 digit I cloud verification code that is constant for a user in records .
Open system preferences > internet account > check the box of mail a window will appear , enter your password for web mail ( can be gmail or yahoo ….) to get it configured .
Again click on I cloud , you will see the keychain box is unchecked , check it after few minutes a pop up will come on the desktop to enter 4 digit I cloud verification code , so you have enter it and click on ok ..
Be patient after few minutes an sms will come to your registered mobile ( that would be 6 digit ) , so enter it .
You will observe the keychain box is configured .
If you are using air port express , open it with the help of spotlight , click on base station your base station is empty , click on edit and enter your base station or wireless network password ( both are kept as same generally ) , as base station password should be filled up always for security purpose .
I have tested this procedure two times on my computer and it worked .
Note : The most important role was of 4 digit iCloud verification code and all passwords that were safely written in records .
Please try this method and hope so , it can help you .
This method was applied for Mac OS Sierra 10 .12.6