Log into mysql
mysql -u root -p
List users
select User,Host from mysql.user;
Set password
set password for 'root'@'localhost' = PASSWORD('password');
On new versions of MySQL you may need to use
alter user 'root'@'localhost' IDENTIFIED BY 'password';