To set the MySQL root password, follow these steps:
-
Access MySQL as the root user:
sudo mysql -
Set the root user password using the following command:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourNewPassword';Replace
YourNewPasswordwith the desired password (e.g.,4nM1ruJNqL1D). -
Exit the MySQL database:
exit;
After completing these steps, the root password will be set. You can log in using:
mysql -uroot -pYourNewPassword
