1. Download MySQL Archive (decompressed version) from the official website
URL: https://downloads.mysql.com/archives/community/
2. Unzip the file to the custom installation directory:
There is no "data" folder and "my.ini" configuration file after extraction
3. Configure environment variables after decompression
New system variable "MYSQL_HOME" value: the root path of the custom installation directory: xxx\mysql-5.7.20-winx64
Additional Path :;% MYSQL_HOME% \ bin
4. Create the "my.ini" configuration file in the root directory of the custom installation path
Configuration information:
[client]
port = 3306
[mysqld]
port = 3306
basedir=%MYSQL_HOME%
datadir=%MYSQL_HOME%\data
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
# skip password
skip-grant-tables
5. Initialize and install MySQL:
cmd terminal (recommended to run with administrator privileges)
>mysqld --initialize
>mysqld -install //Install the MySQL service and you can view the service in services.msc
>net start/stop mysql //Open and close mysql
>mysql -u root -p
enter password: Enter directly
mysql>update mysql.user set authentication_string=password('123') where user='root' and host='localhost';
mysql>flush privileges;
exit mysql
to my.ini comment out skip-grant-tables
After logging in to MySQL, you will be prompted:
mysql error You must reset your password using ALTER USER statement before executing this statement.
mysql>SET PASSWORD=PASSWORD('123');
mysql>ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
mysql>flush privileges;
Just log in again