Font Size:
Ask Joget AI

Installing MySQL as a Windows Service

Introduction

To install MySQL as a Windows service, follow these steps:

Installation Process

Download and Extract

  1. Go to official Download MySQL page and download the ZIP Archive.
  2. Extract and move the downloaded ZIP file so you end up with a directory displayed in the image below.

Create the Config File

Create the config file C:\mysql\my.ini with this content:

[mysqld]
basedir=C:/mysql
datadir=C:/mysql/data
port=3306
max_connections=100
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci

[client]
port=3306
default-character-set=utf8mb4

Initialize the Data Directory

Open Command Prompt as Administrator and execute:

cd C:\mysql\bin
mysqld --defaults-file=C:\mysql\my.ini --initialize --console

The output:

Near the end of the output, you will see a line like:

[Note] [MY-010454] [Server] A temporary password is generated for root@localhost: >4S-5BMq??v1

Copy the password, use --initialize-insecure to start with a blank root password.

Install the Windows Service

In Command Prompt, run the following command:

mysqld --install MySQL84 --defaults-file=C:\mysql\my.ini

MySQL84 is the service label, choose your own suitable label. You should see a " Service successfully installed." message.

Start the Windows Service

Start the service by running the following command:

net start MySQL84

Note
Alternatively, you can start the service through services.msc.

Set the root password

In Command Prompt, run:

mysql -u root -p

Enter the temporary password and then exit.

Add MySQL to PATH (optional)

To run MySQL from any directory, set MySQL to PATH. Press Win+R, enter sysdm.cpl, and navigate to Advanced > Environment Variables. Edit the Path under System variables and add C:\mysql\bin.

Expected Outcome

By following these steps, you will have MySQL installed and configured to run as a Windows service.

Created by Aadrian Last modified by Nur Baizura Badrul Sham on Sep 08, 2026