MySQL Command line to Reset User Password Using Ubuntu 22.04
Jun 29, 2022 . Admin
Hi Guys,
Today, How to Reset the Root Password? is our main topic. let’s discuss about Step by Step Guide to Reset Root Password in MySQL. we will help you to give example of Forgotten MySQL Root Password. let’s discuss about Reset the MySQL Root Password. Alright, let’s dive into the steps.
You can use this post for ubuntu 14.04, ubuntu 16.04, ubuntu 18.4, ubuntu 20.04, ubuntu 21 and ubuntu 22.04 versions.
Step 1: Login to the MySQL shell as rootIn order to change the password using mysqladmin, the syntax is easy:
mysqladmin -u USER -p passwordStep 2: Set the MySQL user password
For MySQL 8 on Ubuntu, run following commands.
UPDATE mysql.user SET authentication_string=null WHERE User='root'; flush privileges;
Replace your_password_here with your own.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password_here';Step 3: Start MySQL Server
Now, we start MySQL normally:
sudo service mysql startStep 4: Verify the new password
Now, check the new password is working or not for root user.
$ mysql -u root -p
By following any of the above SQL statements, you can easily change the password of any existing MySQL user.