I am using XAMPP to run Apache server with PHP and MySQL. As you install XAMPP it set the MySQL password to empty by default. To change the password you can navigate to http://localhost/phpmyadmin (remember to include your port if you had to use a different port number than 80). Then click on SQL and enter the following query to reset the password to ‘whatever’
UPDATE mysql.user SET Password=PASSWORD('whatever') WHERE User='root'; FLUSH PRIVILEGES;
Press Go and you should get this screen:
Then you’d get an error as below indicating that you cannot connect to MySQL.
Now you need to update the root password in the config.inc.php file which would be located in the directory where you installed xampp. In my case it is in C:\xampp\phpMyAdmin\config.inc.php
Then update the following line to include the ‘whatever’ password.
$cfg['Servers'][$i]['password'] = '';
Reference: http://veerasundar.com/blog/2009/01/how-to-change-the-root-password-for-mysql-in-xampp/