|If you administer a server and have forgotten the MySQL password of the |
Note that in Windows, if you've not added the MySQL's bin folder to the system path, you will have to navigate in the commndline ("DOS") window to that folder to execute these commands.
1. Stop MySQL:
Win: Stop it in services.msc, or run ...
Mac with MySQL 5.7:
2. Sometimes in Windows it is necessary to uncomment this line in %windir%system32driversetchosts:
3. Start the MySQL server specifying your defaults-file (if you don't know that filename, see "What config file is the MySQL server using?"), and bypassing authentication ...
*Nix or Mac:
4. In another commandline window, start the mysql client:
5. Verify that the name of the admin user is 'root'; you cannot create users when running with skip-grant-tables):
6. Change root user's password
Substitute the desired root password for 'new_pwd':
7. Stop mysqld in Task Manager or (*Nix, Mac) in another command window...
8. Restart MySQL:
Win: restart the services in services.msc, or run ...
For more detail see https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html or https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html.