Reset root password in MySQL

View previous topic View next topic Go down

Reset root password in MySQL

Post by BIT0122-Amit on Sat Mar 12, 2011 7:59 pm

Today my friend Jobaer asked me to help him reset his password in mysql. He apparently forgot what his password was. And he tried in many ways to reset/change it. None worked. So I decided to give a look.

After a while, I found exactly how to reset mysql password Very Happy The steps are:

Stop MySQL server.

Code:
sudo /etc/init.d/mysql stop


Start MySQL Daemon with grant table skipping.
Code:

sudo mysqld_safe --skip-grant-tables &


Login to MySQL server using username root

Code:
mysql -u root

now, get inside mysql database where user information is kept.

Code:
use mysql;

After that, simply change the password using this command:

Code:
update user set password=PASSWORD("NEW-PASSWORD") where User='root';



Now, flush privileges

Code:
flush privileges;


And then, restart mysql server.

Code:
/etc/init.d/mysql stop

/etc/init.d/mysql start


Test your mysql Password:

Code:
mysql -u root -p


when asked, enter your new password Very Happy

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|

BIT0122-Amit
Founder
Founder

Course(s):
  • BIT

Blood Group: O+
Posts: 4187
Points: 6601

View user profile http://iitdu.forumsmotion.com

Back to top Go down

View previous topic View next topic Back to top


Permissions in this forum:
You cannot reply to topics in this forum