|If you administer a server and have forgotten your MySQL password, do this sequence. |
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 DOS window to that folder to execute these commands.
If your MySQL version is earlier than 5.5.7, substitute
1. Stop MySQL:
Win: Stop it in services.msc, or run ...
Mac with MySQL 5.7:
2. 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:
3. In another command window, start the mysql client:
4. Find the name of the admin user (probably 'root'; you cannot create users when running with skip-grant-tables), update that user's password:
(Substitute your password for 'new_pass'.)
5. Stop mysqld in Task Manager or (*Nix, Mac) in another command window...
4. Restart MySQL:
Win: restart the services in services.msc, or run ...
For more detail see http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html