I am not sure which distro you are using, but the following should work:
add 'skip-grant-tables' to the MySQL server's 'my.cnf' usually found at '/etc/my.cnf. Needs to go under the '[mysqld]' section. Similar to:
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
Then restart MySQL:
You should then be able to login to mysql without a password:
linuxbox /]# mysql
Now flush privileges (This clears privileges back to where they should be without 'skip-grant-tables')
mysql> FLUSH PRIVILEGES;
Then reset the root user's password:
mysql> SET PASSWORD FOR 'root'@'localhost'=PASSWORD('password');
Where 'password' is the cleartext password you want to set for root@localhost
Now remove 'skip-grant-tables' from '/etc/my.cnf' and you are all set.