Restart your CentOS 7 system. During the reboot, press ‘e’ on the GRUB menu to enter the boot configuration.
In the GRUB editor, locate the line starting with "linux16" or "linux". Add rd.break at the end of this line.
Press Ctrl + X to boot into single user mode. The system will stop at the initramfs prompt.
Remount the system's root directory as read/write using the command: mount -o remount,rw /sysroot
Change root to access the system using the command: chroot /sysroot
Use the command passwd to reset the root password. Enter the new password when prompted.
Type touch /.autorelabel to relabel SELinux contexts, exit the shell, and reboot the system using reboot.