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!
Latest posts by Dan Nanni (see all)
- How to switch from NetworkManager to systemd-networkd on Linux - August 31, 2015
- How to set up a system status page of your infrastructure - August 25, 2015
- How to configure virtual hosts in Apache HTTP server - August 24, 2015