Start the MySQL server with the special --init-file option (notice that the backslash in the option value is doubled):
Press CTRL+C to copyC:\> cd "C:\Program Files\MySQL\MySQL Server 5.7\bin"C:\> mysqld --init-file=C:\\mysql-init.txt If you installed MySQL to a different location, adjust the cd command accordingly.
The server executes the contents of the file named by the --init-file option at startup, changing the 'root'@'localhost' account password.
To have server output to appear in the console window rather than in a log file, add the --console option to the mysqld command.
If you installed MySQL using the MySQL Installation Wizard, you may need to specify a --defaults-file option. For example:
Press CTRL+C to copyC:\> mysqld --defaults-file="C:\\ProgramData\\MySQL\\MySQL Server 5.7\\my.ini" --init-file=C:\\mysql-init.txt The appropriate --defaults-file setting can be found using the Services Manager: From the Start menu, select Control Panel, then Administrative Tools, then Services. Find the MySQL service in the list, right-click it, and choose the Properties option. The Path to executable field contains the --defaults-file setting.