How to Change MySQL Root User Password Ubuntu?

06-Jul-2023

.

Admin

How to Change MySQL Root User Password Ubuntu?

Hello Friends,

In this example, you will learn how to change the mysql root user password ubuntu using the command line. you can understand the concept of resetting a mysql root password in Ubuntu. we will help you to give an example of changing the mysql root password in linux. you can understand how to reset your mysql root password on Ubuntu.

Change MySQL root user password using the command line on Ubuntu: In this tutorial, you will learn how to change the MySQL user or 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 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.

I hope it can help you...

#Ubuntu