1. Power down and pull the SD card out from your
Pi and put it into your computer.
2. Open the file 'cmdline.txt' and add 'rw init=/bin/sh' to the end. This will cause the machine to boot to single user mode.
(-------> Then, maybe 'cmdline.txt' will be changed 'dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
rw init=/bin/sh')
3. Put the SD card back in the
Pi and boot.
4. When the logs stop to come up, press 'enter'
5. Then the prompt comes up, type 'su' to log in as root (no password needed).
6. Type "passwd
pi" and then follow the prompts to enter a new password.
7. Shut the machine down, then pull the card again and put the cmdline.txt file back the way it was by removing the 'rw init=/bin/sh' bit.
That' all. If you insert just 'init=/bin/sh', it has just read permission, so you should add 'rw' in front of 'init=/bin/sh'