Thursday, August 28, 2025
HomeGuest BlogsHow to Change MySQL Root User Password Linux ubuntu using Command Line

How to Change MySQL Root User Password Linux ubuntu using Command Line

Change Mysql root user password using the command line ubuntu; Through this tutorial, you will learn how to change the Mysql user or root user password on Linux ubuntu using the command line.

How to Reset / Change MySQL User Password Command Line Linux ubuntu

By using the following steps, you can reset or change the MySQL user password on Linux ubuntu 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 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 – Start MySQL Server

Execute the following command on the command line or terminal 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, you have learned how to change or reset the Mysql user password on Linux Ubuntu 22.04 using the command line.

Recommended Linux Ubuntu Tutorials

RELATED ARTICLES

Most Popular

Dominic
32236 POSTS0 COMMENTS
Milvus
80 POSTS0 COMMENTS
Nango Kala
6609 POSTS0 COMMENTS
Nicole Veronica
11779 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11828 POSTS0 COMMENTS
Shaida Kate Naidoo
6719 POSTS0 COMMENTS
Ted Musemwa
7002 POSTS0 COMMENTS
Thapelo Manthata
6678 POSTS0 COMMENTS
Umr Jansen
6690 POSTS0 COMMENTS