Ubuntu
Nicesnippets
29-06-2022
Hi Guys,
This example is focused on MySQL Change a User Password Command Tutorial. we will help you to give example of 4 Best Ways to Change MySQL User Password by Examples. you can see How to reset the MySQL root password?. This article will give you simple example of Reset MySQL Root Password on Ubuntu .
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 root
In order to change the password using mysqladmin, the syntax is easy:
mysqladmin -u USER -p password
Step 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 start
Step 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.