Change Mysql user password using command line ubuntu 22.04; Through this tutorial, we will learn how to change the Mysql user password on Linux ubuntu 22.04 using the command line.
How to Change MySQL User Password Command Line
Use the following steps to change the MySQL user password on Linux ubuntu 22.04 using the command line:
- Step 1 – Login to the MySQL shell as a root
- Step 2 – Set the MySQL user password
- Step 3 – Start MySQL Server
- Step 4 – Verify the new password
Step 1 – Login to the MySQL shell as root
First of all open the command prompt and execute the following command into the command line to access the MySQL root user:
mysql -u root -p
Step 2 – Set the MySQL user password
Execute the following commands on the command line to change MySQL 8.0 user password on 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 – Start MySQL Server
Execute the following command on the command line to restart start MySQL server:
sudo systemctl start 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.
Conclusion
Through this tutorial, we have learned how to change the Mysql user password on Linux ubuntu 22.04 using the command line.