Change MySQL root password

If you have MYSQL root password and want to change the MySQL root password, first log in to MYSQL with the command

mysql -u root -p

Method 1

UPDATE mysql.user SET Password=PASSWORD('MYSQL_ROOT_PASSWORD') WHERE User='root';
FLUSH PRIVILEGES;

Method 2

Advertisement

ALTER USER 'root'@'localhost' IDENTIFIED  BY 'MYSQL_ROOT_PASSWORD';

OR

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'MYSQL_ROOT_PASSWORD';

Method 3

Use command

mysqladmin -u root -p password

This command will ask for new and old MySQL password.

Add a comment

Leave a Reply

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

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Advertisement