How to change MySQL root password in Linux

In this article, we will see how to change MySQL root password in Linux. We can change the password with multiple methods, below are the few of them.

1. Update root user password using SET method:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD("admin@123"); flush privileges;

2. Update root user password using ALTER USER method:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'admin@123'; flush privileges;

3. Update root user password using UPDATE method:

UPDATE mysql.user SET PASSWORD=PASSWORD('admin@123') WHERE user='root' AND Host='localhost'; flush privileges;

4. On latest versions, we can change the current user with below method:

select current_user(); set password = 'new_password'; flush privileges;

So in this article, we explained different methods to change MySQL root password on Linux.

Leave a Reply

Your email address will not be published. Required fields are marked *