Stop mysqld and restart it with the –skip-grant-tables –user=root

shell> mysql -u root -e "UPDATE mysql.user SET Password=PASSWORD('**newpwd**') WHERE User='root';"
shell> mysql -u root -e "FLUSH PRIVILEGES;"

Replace “newpwd” with the actual root password that you want to use.