If you want to set a root password for MySQL when there is no root password, you can follow these steps:
- Login to MySQL as the root user (without a password):
- Set a new password for the root user:
sql
ALTER USER 'root'@'localhost' IDENTIFIED BY 'your_new_password';
Replace your_new_password with the desired password.
- Flush privileges to apply the changes:
- Exit the MySQL shell:
After completing these steps, the root user should have the new password you specified. Make sure to replace your_new_password with a strong and secure password.