Stop mysqld and restart it with:
# service mysqld stop
# mysqld_safe --skip-grant-tables --user=root
Connect to the mysqld server with this command:
sql> mysql -u root
Issue the following statements in the mysql client:
mysql> UPDATE mysql.user SET Password=PASSWORD('newpassword') WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> QUIT;
Stop mysqld and restart it with:
# service mysqld stop
# service mysqld start