Follow the steps below:
1)centos> /etc/rc.d/init.d/mysqld restart
2)centos> mysqld_safe --skip-grant-tables &
3)centos>mysql -u root
4)mysql> UPDATE mysql.user SET Password=PASSWORD(’newpwd’)
-> WHERE User=’root’;
5)mysql> FLUSH PRIVILEGES;
note:
------
#Replace ‘newpwd’ with the actual root password that you want to use.
# You should be able to connect using the new password.