Last updated on May 4, 2012 by Dan Nanni
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.
$ sudo /etc/init.d/mysql stop $ 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 mysqld_safe --init-file=/tmp/run & $ sudo /etc/init.d/mysql restart $ rm /tmp/run
This website is made possible by minimal ads and your gracious donation via PayPal or credit card
Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.
Xmodulo © 2021 ‒ About ‒ Write for Us ‒ Feed ‒ Powered by DigitalOcean