If you want to change the password of the root user of MySQL in your Ubuntu system, you have to type 3 commands such as sudo mysql, use mysql, AND UPDATE USER SET authentication_string = password(“new_password”) WHERE user = “root”, on the command line.
Through this tutorial, we will show you how to change the Mysql user or root user password on Linux ubuntu using the command line.
How to Reset or Change MySQL Root User Password on Linux ubuntu
Here are some steps for changing or resting the MySQL root user password on Linux ubuntu using the command line:
Step 1 – Login to the MySQL shell as root
First of all open the command line and execute the following command into the command line to access the MySQL root user:
mysql -u root -p
Step 2 – Change the MySQL Root user password
Execute the following commands on the command line or terminal to change MySQL 8.0 user password on the Linux Ubuntu system:
UPDATE mysql.user SET authentication_string=null WHERE User='root'; FLUSH PRIVILEGES;
Replace new_password
with your own password:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new_password';
Step 3 – Restart MySQL Server
Execute the following command on the command line or terminal to restart start MySQL server:
sudo systemctl restart mysql
Step 4 – Verify the new password
Execute the following command on the command line to verify that the new password has been applied correctly type:
Login to MySQL using the new password.
sudo mysql -u root -p
Enter the new password you set before when prompted.
Here is the video guide on how to change MySQL root user password on ubuntu using command line:
Conclusion
Through this tutorial, you have learned how to change or reset the Mysql user password on Linux Ubuntu 22.04 using the command line.