Google News
logo
MySQL - Interview Questions
How to change the MySQL password?
We can change the MySQL root password using the below statement in the new notepad file and save it with an appropriate name:
 
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword';
 
Next, open a Command Prompt and navigate to the MySQL directory. Now, copy the following folder and paste it in our DOS command and press the Enter key.
 
C:\Users\javatpoint> CD C:\Program Files\MySQL\MySQL Server 8.0\bin
 
Next, enter this statement to change the password:
 
mysqld --init-file=C:\\mysql-notepadfile.txt
 
Finally, we can log into the MySQL server as root using this new password. After launches the MySQL server, it is to delete the C:\myswl-init.txt file to ensure the password change.
Advertisement