Saturday, June 3, 2017

How to Reset Mysql root password

Forgot mysql root password ? No worries here is how I reset mine on by debian 9 Box.Usually it boils down to starting service
in safe mode & updating password & then restrating it normally.

Here are the steps


1) First Stop mysql service

       sudo service mysql stop

2) Start mysql in safe mode

        sudo mysqld_safe –skip-grant-tables

3) In Another Terminal login as root mysql user no password needed

         mysql -u root

4) Update your root password using SQL Query for that first switch to mysql database which stores login and password.

          use mysql;

 5) Update password

         update user set password=PASSWORD(‘your_password_goes_here’) where where User='root';

6) Ask Mysql to reload previlages to make changes take effect

        flush privileges;

7) Now time to test if change:

we made are working fine first exit from mysql command prompt by issuing  'exit'.also close the mysql running in safe mode by going to corresponding terminal  & pressing  "control + c" until it stops.

8) Lets start mysql in normal way using service dameon

          sudo service mysql start

Once service is up try to login through command line use password you just assigned.
                  mysql -u root -p

    it works !

No comments:

Post a Comment