In this tutorial, i am going to show you how to change the Mysql user password on Linux ubuntu 22.04 using the command line.
How to Change MySQL User Password Command Line
Follow the below given 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
Start terminal or command prompt and run the following command into the command line to access the MySQL root user:
mysql -u root -p
Step 2 – Set the MySQL user password
Run 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
Run the following command on the command line to restart start MySQL server:
sudo systemctl start mysql
Step 4 – Verify the new password
Run 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, i have shown to you how to change the Mysql user password on Linux ubuntu 22.04 using the command line.