How to reset mysql root password on linux

Published: 25 June 2020
on channel: Technical Skills Linux
9,219
63

Reset MySQL database root password

This video shows how to reset password for the root user in MySQL database in case the password was forgotten

Step by step:--
Step 1:- Stop MySQL
sudo service mysql stop

Step 2:- Make MySQL service directory.
sudo mkdir /var/run/mysqld

Step 3:- Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld

Step 4:- Start MySQL manually, without permission checks or networking.
sudo mysqld_safe --skip-grant-tables --skip-networking &

Step 5:- Log in without a password.
mysql -uroot mysql

Step 6:-For change password
UPDATE mysql.user SET authentication_string = PASSWORD('newreset_password') WHERE User = 'root' AND Host = 'localhost';

Step 7:-flush privileges;

Step 8:- Start the MySQL service normally.
sudo service mysql start

Step 9:-sudo mysql -u root -pnewreset_password


Thank you for watching