If you forgot the root password in MySQL, and would like to reset it, do the following as root. In this example, replace "NewPassword" with your own password.
First create a MySQL script in /tmp/run as follows.
$ vi /tmp/run
UPDATE mysql.user SET Password=PASSWORD('NewPassword') WHERE User='root'; FLUSH PRIVILEGES;
Then run mysqld_safe pointing to the script you created.
$ sudo /etc/init.d/mysql restart
$ rm /tmp/run
Subscribe to Xmodulo
Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!