Databases 7 min read

How to Fix MySQL Service Won’t Start on Windows: Step‑by‑Step Guide

This guide walks you through diagnosing MySQL service startup failures on Windows, initializing the data directory, retrieving the auto‑generated root password, and resetting it so you can successfully log in and use MySQL again.

Python Crawling & Data Mining
Python Crawling & Data Mining
Python Crawling & Data Mining
How to Fix MySQL Service Won’t Start on Windows: Step‑by‑Step Guide

When MySQL fails to start on Windows, you may see errors such as "Windows cannot start the MySQL57 service (on local computer) error 1067: The process terminated unexpectedly" or "The MySQL service stopped after starting".

Step 1: Run the command line as Administrator. This prevents "System error 5. Access denied" messages.

Step 2: Locate the MySQL bin directory. The default path is C:\Program Files\MySQL\MySQL Server 5.7\bin. Use cd and dir to navigate there.

Step 3: Prepare the data folder. If a data directory does not exist beside bin, create an empty one named data. If it exists, clear all files inside.

Step 4: Initialize the data directory. Execute mysqld –initialize from the bin folder. The process takes about 20 seconds.

After initialization the MySQL service starts automatically and the MySQL Notifier shows the status changing from stopped to running.

Step 5: Log in to MySQL. Use mysql –u root -p. The original password will no longer work because MySQL generated a new temporary password.

The temporary password is stored in an .err file inside the data folder. Open the file with a capable editor (e.g., Sublime Text) and search for the word "password" to locate it.

Copy the retrieved password and use it to log in.

Step 6: Reset the root password. After logging in, run:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'YourNewPassword';

Replace YourNewPassword with a password of your choice, then execute FLUSH PRIVILEGES; to apply the changes.

After these steps MySQL should be fully operational, and you can continue using it for your projects.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

databasemysqlServiceInitialization
Python Crawling & Data Mining
Written by

Python Crawling & Data Mining

Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.