How To Reset Mysql Root Password

Firstly bring the MySQL service down.

/etc/init.d/mysqld stop

Then fire the below commands :-

/usr/bin/mysqld_safe –skip-grant-tables &

mysql –user=root mysql

YOU WILL SEE:
#############################
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.0.45 Source distribution

Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the buffer.

mysql>update user set Password=PASSWORD(’NEWPASSWORD‘) WHERE User=’root’;
##########################

Query OK, 2 rows affected (0.00 sec)
Rows matched: 2 Changed: 2 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

/etc/init.d/mysqld start

mysql –user=root –pass=NEWPASSWORD

Now try to login

0 comments:

Post a Comment