Linux Networking Ubuntu

Reset MySQL root password in Ubuntu 20.04

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: On another console, log in without a password.
mysql -u root mysql
Step 6: Update new password
UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='localhost';
Step 7: Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
Step 8: Start the MySQL service normally.
sudo service mysql start

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.