How to Update a root password

# mysqladmin -u root -p oldpassword newpassword

To update the root password in MySQL, you can follow these steps:

  1. Log in to MySQL as the root user:
    bash
    mysql -u root -p
  2. Enter the current root password when prompted.
  3. 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.

  4. After updating the password, flush the privileges to apply the changes:
    sql
    FLUSH PRIVILEGES;
  5. 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.