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 use Mutt email client with encrypted passwords - December 1, 2015
- How to back up a WordPress website to remote cloud storage from the Linux command line - November 24, 2015
- How to access Dropbox from the command line in Linux - November 22, 2015