Databases 8 min read

Step-by-Step Guide to Installing and Configuring MySQL on Windows

This article walks you through MySQL's default ports, provides a concise introduction, details how to download the Community Server, explains extraction, environment variable setup, configuration file creation, service registration, and shows essential commands for initializing, starting, stopping, and managing MySQL users on Windows.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Step-by-Step Guide to Installing and Configuring MySQL on Windows

Common Database Ports

MySQL: 3306

Redis: 6379

MongoDB: 27017

Django: 8000

Flask: 5000

What Is MySQL?

MySQL is an open‑source relational database management system originally developed by MySQL AB and now owned by Oracle.

It is one of the most popular RDBMS for web applications, known for low cost, high speed, small footprint, and open source code.

Downloading MySQL Server

1. Open the official website

https://www.mysql.com

2. Click "Downloads"

3. Choose "MySQL Community Server"

4. Select the version

Installing MySQL

1. Extract the archive

Right‑click the zip file and extract it (you may rename the folder).

2. Configure environment variables

Open System Settings and search for "environment variables".

Add MySQL's bin directory to the PATH.

3. Open a terminal as administrator

Press win+r, type cmd, and run as administrator.

4. Create MySQL configuration file

Create a file named my.ini in the MySQL installation directory.

Copy and edit the following content:

[mysqld]
# Set port
port=3306
# Installation directory
basedir="D:\python_studyclass\MySQL"
# Data directory
datadir="D:\python_studyclass\MySQL\data"
max_connections=200
max_connect_errors=10
character-set-server=utf8mb4
default-storage-engine=INNODB
default_authentication_plugin=mysql_native_password
[mysql]
default-character-set=utf8mb4
[client]
port=3306
default-character-set=utf8mb4

Create a data folder under the installation directory.

5. Initialize MySQL server

Run the following command:

mysqld --initialize --console
# Note the temporary password displayed, e.g. fG)m:;rvz9Z#

6. Register MySQL as a Windows service

Open Services (search "services" or use Computer Management).

Execute:

mysqld --install

7. Start and stop the service

Start via GUI or run: net start mysql Stop with:

net stop mysql

Basic MySQL Operations

1. Login and logout

# Local login (enter password when prompted)
mysql -uroot -p
# Login with password in command line
mysql -uroot -p123456
# Remote login example
mysql -h 192.168.1.63 -P 3306 -uroot -p123456
# Exit
quit;

2. Change password

Log in with the temporary password.

alter user 'root'@'localhost' identified by '123456';
flush privileges;

3. Reset forgotten password

Stop the MySQL service. net stop mysql Start MySQL without grant tables: mysqld --skip-grant-tables Open another admin terminal and log in without a password.

mysql -uroot -p
# Press Enter when prompted for password

Reset the password and flush privileges.

alter user 'root'@'localhost' identified by 'new_password';
flush privileges;

4. Skip password entry (modify my.ini)

[mysql]
user="root"
password=your_password
default-character-set=utf8mb4
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.

databaseConfigurationmysqlcommand-lineWindowsInstallation
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

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.