reset root password of mysql

Step 1: Stop MySQL Service.
sudo service mysql stop
Step 2: Kill all running mysqld.
sudo killall -9 mysqld
Step 3: Starting mysqld in Safe mode.
sudo mysqld_safe --skip-grant-tables --skip-networking &
Step 4: Start mysql client
mysql -u root
Step 5: After successful login, please execute this command to change any password.
Step 6: You can update mysql root password .
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
for mysql > 5.7 use this instead of above:
UPDATE mysql.user SET authentication_string=PASSWORD('newpwd') WHERE User='root';
Step 7: Please execute this command.
Step 8: Exit mysql console
Step 9: Kill mysqld_safe and start mysql
sudo killall mysqld_safe && sudo service mysql start

Leave a Comment

Your email address will not be published. Required fields are marked *

Open chat