How to set MySQL root password?

To set the MySQL root password, follow these steps:

  1. Access MySQL as the root user:

    sudo mysql
  2. Set the root user password using the following command:

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

    Replace YourNewPassword with the desired password (e.g., 4nM1ruJNqL1D).

  3. Exit the MySQL database:

    exit;

After completing these steps, the root password will be set. You can log in using:

mysql -uroot -pYourNewPassword

0 Comments

no data
Be the first to share your comment!