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

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.

MySQL Password mysql

Comments

Leave a Reply

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