Tuesday, January 11, 2011

How to reset mysql root password in Ubuntu /Debian linux

I for got my mysql root password last week.  , you can reset your mysql root password.
First You have to  Stop mysql server:
#service mysqld stop
Now Start mysql server in safe mode with Follwing Options:
#mysqld_safe –user=mysql –skip-grant-tables –skip-networking &
Now you have to Login to mysql server without password:
#mysql -u root mysql
You will get Mysql Prompt.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql>
Now the Time for Resetting  mysql root password:
Run the following  commands very carefully  ( don’t miss semicolon  )
mysql> UPDATE user SET Password=PASSWORD(‘newrootpassword’) WHERE User=’root’;
mysql> flush privileges;
mysql> exit

5) Restart mysql server:
#service mysqld restart
6) Login to MySQL With the New Password:
root@server ]# mysql -u root -p
Enter password:
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql>

1 comment:

Anonymous said...

Thanks. Worked great