During installation of MySQL 5.7 on Windows, the proccess often fails at the database initialization stage with the error: unknown variable 'mysqlx_port=0.0'. This issue stems from the installer incorrectly including a MySQL 8.0+ specific configuration option (mysqlx_port) in the my.ini file, wich is not recognized by MySQL 5.7.
To resolve this, follow these steps:
-
Locate and edit
my.iniThe configuration file is typically found at:C:\ProgramData\MySQL\MySQL Server 5.7\my.iniOpen it and comment out or remove the line containing
mysqlx_port=0.0. Note that re-running the official installer will regenerate this file and reintroduce the problematic line, so avoid using the GUI installer after this point. -
Clear the data directory Delete all contents in the data folder:
C:\ProgramData\MySQL\MySQL Server 5.7\Data -
Initialize the database manually Open a Command Prompt in the MySQL
bindirectory:C:\Program Files\MySQL\MySQL Server 5.7\binRun the following command to initialize without a password:
mysqld --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.7\my.ini" --console --initialize-insecureIf you encounter encoding issues, save
my.iniwith ANSI encoding and retry. -
Start MySQL manually In the same
bindirectory, launch the server:mysqld --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.7\my.ini" --console -
Set root password In a new terminal window, connect as root (no pasword needed initially):
mysql -u rootThen execute inside the MySQL shell:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'YourNewPassword'; FLUSH PRIVILEGES; EXIT; -
Verify login Test the new credentials:
mysql -u root -p -
Install as a Windows service (if supported) On most Windows editions, the installer registers a service named
MySQL57. If it exists but won’t start, ensure themy.inifile no longer containsmysqlx_port. Start it via Services (services.msc).On Windows 11 Home or systems where the service fails to start, use a batch script to run MySQL manually. Create
start_mysql.batwith:@echo off echo Starting MySQL Server... "C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld" --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.7\my.ini" --console echo. echo MySQL Server started. Press any key to exit... pause >nulFor automatic elevation, use this version:
@echo off net session >nul 2>&1 if %errorLevel% neq 0 ( powershell -Command "Start-Process '%~f0' -Verb runAs" exit /b ) echo Starting MySQL Server... "C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld" --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.7\my.ini" --console echo. echo MySQL Server started. Press any key to exit... pause >nul