Monday, October 8, 2012

Reset MySQL root Password

Hello,

Many times it happens that we do forget the root password for our mysql instance(whether local or on server if you have rights). It also happens, if we start using a system in which mysql was already there and we don't know whats the root login.

Following steps can help in resetting the root password
Note: You must have root privileges or sudo access to execute the commands :)

1) Stop the mysql daemon:
             like: /etc/init.d/mysql stop
2) Start to MySQL server w/o password:
             use skip-grant-tables option while restarting.
3) Connect to mysql server as the root user:
             mysql -u root
4) Setup new mysql root account password i.e. reset mysql password:
             update user set password=PASSWORD("new password") where User='root';
             (we need to enter password in encrypted form, so using password())
5) Exit and restart the MySQL server:
               like: /etc/init.d/mysql restart





Hope this is useful.

No comments:

Post a Comment