Step-by-Step Guide to Install and Configure MySQL 5.7 on Windows
This tutorial walks you through configuring the PATH, editing my-default.ini, installing the MySQL service, initializing and starting it, managing the service, and resetting the root password on a Windows machine using MySQL 5.7.12 (64‑bit).
MySQL 5.7.12 (64‑bit) is installed on Windows by first adding the MySQL bin directory to the system Path environment variable. The path should be placed at the beginning of Path and end with a semicolon, e.g., D:\software\mysql5.7.12\bin;.
Next, edit the my-default.ini file located in the MySQL root directory. Set the basedir to the MySQL installation folder and the datadir to a folder where the database files will be stored; the data directory must be created manually.
Tips: Use backslashes (\) in paths to avoid escaping issues, and ensure the datadir folder exists before proceeding.
Open a command prompt with administrator rights and navigate to the MySQL bin folder (even if Path is configured). This step is required for the following commands.
Install the MySQL service by running mysqld -install. The service can also be installed with an explicit configuration file using
mysqld -install MySQL --defaults-file="D:\software\mysql5.7.12\my-default.ini". A successful installation shows a confirmation message.
Initialize the MySQL data directory with mysqld --initialize. It is recommended to clear the datadir beforehand to avoid initialization errors such as error 3534.
Start the MySQL service using net start mysql. A successful start is confirmed by a message and a screenshot.
Common service commands:
1. Stop the service: net stop mysql 2. Remove the service: mysqld -remove
If the root account requires a password, reset it as follows:
1. Add skip-grant-tables under the [mysqld] section in my-default.ini and restart the service. 2. Log in to MySQL without a password. 3. Check whether the user table contains a password column: select password from mysql.user where user='root'; 4. If the column exists, update the password with: update mysql.user set password=PASSWORD('Aa!12345') where User='root'; 5. If the column does not exist, update the authentication_string column instead: update mysql.user set authentication_string=PASSWORD('Aa!12345') where User='root';
After updating, comment out skip-grant-tables in my-default.ini and restart the MySQL service.
Log in with the new password. If you run select * from mysql.user; and receive error 1820, set the password again using: SET PASSWORD = PASSWORD('Aa!12345'); Finally, verify the change by selecting from the user table.
MySQL password policy requires at least one uppercase letter, one lowercase letter, one special character, one digit, and a minimum length of eight characters.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ITPUB
Official ITPUB account sharing technical insights, community news, and exciting events.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
