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
1 |
mysql -u root -p |
Method 1
1 2 |
UPDATE mysql.user SET Password=PASSWORD('MYSQL_ROOT_PASSWORD') WHERE User='root'; FLUSH PRIVILEGES; |
Method 2
1 |
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MYSQL_ROOT_PASSWORD'; |
OR
1 |
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'MYSQL_ROOT_PASSWORD'; |
Method 3
Use command
1 |
mysqladmin -u root -p password |
This command will ask for new and old MySQL password.