Manual Installation and Configuration of MySQL 5.7 on Windows
Acquiring the Software
Navigate to the official MySQL Community Archives to obtain the specific 5.7 distribution package compatible with Windows. Ensure you select the ZIP Archive version for a manual installation setup.
Directory Structure and Preparation
Extract the downloaded archive to a desired location, such as C:\Database\MySQL57. Inside this root directory, create a new folder named data to store database files. Additionally, create a configuration file named my.ini in the root directory.
Server Configuration (my.ini)
Configure the initialization parameters using the following template. Adjust file paths to match your specific extraction directory.
[mysqld]
# Server Connection Settings
port = 3306
# Directory Paths
basedir = C:/Database/MySQL57
datadir = C:/Database/MySQL57/data
# Connection Limits
max_connections = 200
max_connect_errors = 10
# Character Set and Collation
character-set-server = utf8
collation-server = utf8_general_ci
# Storage Engine
default-storage-engine = INNODB
# Authentication Plugin
default_authentication_plugin = mysql_native_password
[mysql]
default-character-set = utf8
[client]
port = 3306
default-character-set = utf8
System Service Installation
Open the Command Prompt as an administrator. Navigate to the bin directory of your MySQL installation.
REM Initialize the database and generate a temporary root password
mysqld --initialize --console
REM Install MySQL as a Windows service
mysqld --install MySQL57
REM Start the service
net start MySQL57
If the standard installation command fails, use the Service Control (sc) utility to create the service manually by specifying the binary path and configuration file explicitly.
sc create MySQL57 binPath= "C:\Database\MySQL57\bin\mysqld.exe --defaults-file=C:\Database\MySQL57\my.ini" start= auto DisplayName= "MySQL 5.7 Server"
REM To remove the service
sc delete MySQL57
Initial Access and Credential Update
Log in using the temporary password generated during the initialization step. Once connected, update the credentials immediately.
-- Login to the server
mysql -u root -p
-- Update the root password for MySQL 5.7
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('NewStrongPassword123!');
-- Grant remote access privileges if necessary
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'NewStrongPassword123!' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Recovering Lost Root Passwords
If the root password is forgotten, restart the service with permission checks disabled to reset the credentials.
- Stop the MySQL service via the command line:
net stop MySQL57. - Start the server manually bypassing grant tables:
mysqld --skip-grant-tables --shared-memory - Open a new command prompt window and connect to the server:
mysql -u root - Reload privileges and update the password:
FLUSH PRIVILEGES; USE mysql; UPDATE user SET authentication_string = PASSWORD('RecoveryPassword') WHERE User = 'root' AND Host = 'localhost'; FLUSH PRIVILEGES; EXIT; - Restart the MySQL service normally and log in with the new password.