How to reset mysql root password in Ubuntu

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> 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s