How to Reset Root Password of MySql

Posted By : Rajat khurana | 09-Apr-2017

Many time user forget their mysql root password which is required during login in mysql. To get rid of this problem , some users uninstall the mysql and install it again which is not appropirate solution. The exact solution to this problem is to change root password which require some manual work of 5 to 10 min.  So, here is procedure to reset the root password of mysql :

1. Login as an Admininstrator on system.

2. Stop the mysql service . To stop it on window go to Control Panel, then  Admininstrative Tools,  then Services . Find mysql services from it and stop it.

3.  Create a text file and place below code in it and save it with name "mysql-init.txt".

UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
FLUSH PRIVILEGES;

Here MyNewPass is new password value to be set and update command update the password , FLUSH statement tells the server to reload the grant tables into memory.

4.  Open command promt (cmd) and run these command . Remember command can be change based on location where mysql is installed. 

C:\> cd "C:\Program Files\MySQL\MySQL Server 5.7\bin"
C:\> mysqld --init-file=C:\\mysql-init.txt

Similarly command is made on Ubuntu. The server execute this file on startup and change password.

5. Restart the server and after that your password is change . After that there is no need of this file so delete it from system.

These are various step you need to follow for reset root password of mysql.

  

About Author

Author Image
Rajat khurana

Rajat is a bright Javascript Developer, he has good knowledge of HTML, WordPress, NodeJs, Core Java, Javascript, Jquery. Apart from this he loves to play Badminton and PC Gaming.

Request for Proposal

Name is required

Comment is required

Sending message..