1 ) First we have to stop MySQL service.
:: Command to Stop MySQL ::
For Ubuntu & Debian : "/etc/init.d/mysql stop"
& CentOS, Fedora, and RHEL : "/etc/init.d/mysqld stop"
2 ) Now we need to start MySQL service in safe mode, in safe mode MySQL will not load user privileges table.
:: Command for safe mode ::
"mysqld safe --skip-grant-tables"
Once you Execute above mentioned command mysql will start in safe mode.
Now, Follow below mentioned Commands to reset root password.
"mysql -u root" (Login into MySQL)
"use mysql;" (for use mysql database in MySQL)
"update user set password=PASSWORD ("yournewpassword") where User='root';" (Command for reset Password)
"flush privileges;" (to save configuration)
"quit" (for exit from MySQL)
Just simply Execute command for stop and start
"/etc/init.d/mysql stop" (to stop MySQL)
"/etc/init.d/mysql start" (to start MySQL)
Now, we need to check mysql password with login into MySQL.
"mysql -u root -p"
You will be prompted for your new password.
Its done Enjoy !!!! :)
:: Command to Stop MySQL ::
For Ubuntu & Debian : "/etc/init.d/mysql stop"
& CentOS, Fedora, and RHEL : "/etc/init.d/mysqld stop"
2 ) Now we need to start MySQL service in safe mode, in safe mode MySQL will not load user privileges table.
:: Command for safe mode ::
"mysqld safe --skip-grant-tables"
Once you Execute above mentioned command mysql will start in safe mode.
Now, Follow below mentioned Commands to reset root password.
"mysql -u root" (Login into MySQL)
"use mysql;" (for use mysql database in MySQL)
"update user set password=PASSWORD ("yournewpassword") where User='root';" (Command for reset Password)
"flush privileges;" (to save configuration)
"quit" (for exit from MySQL)
Just simply Execute command for stop and start
"/etc/init.d/mysql stop" (to stop MySQL)
"/etc/init.d/mysql start" (to start MySQL)
Now, we need to check mysql password with login into MySQL.
"mysql -u root -p"
You will be prompted for your new password.
Its done Enjoy !!!! :)