# mysqladmin -u root -p oldpassword newpassword
To update the root password in MySQL, you can follow these steps:
- Log in to MySQL as the root user:
bash
mysql -u root -p
- Enter the current root password when prompted.
- Once logged in, use the following SQL command to update the root password:
sql
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
Replace
'new_password'
with your desired new password. - After updating the password, flush the privileges to apply the changes:
sql
FLUSH PRIVILEGES;
- You can then exit MySQL by typing:
sql
exit;
Remember to keep your MySQL root password secure and ensure that it meets any security requirements you may have in your environment.