1. First, you need to download the decompressed version of MySQL, download address: https://www.mysql.com/downloads/, diagram:
2. Unzip the installation package and choose the path according to your own preferences. The path I chose is C:\software\, so the full path of MySQL is: C:\software\mysql-5.7.21-winx64
3. Configure environment variables
Add system environment variables:
Key name: MYSQL_HOME
The value is: C:\software\mysql-5.7.21-winx64
Add in Path: %MYSQL_HOME%\bin, note that the ";" symbol between different values in Path cannot be omitted
4. Prepare the my.ini file. You can create a new my.txt file first, and then modify the file suffix to .ini by renaming. The my-default.ini file may exist after the previous version is decompressed, but the 5.7.21 version does not. , so you need to manually create the file yourself, the content of the file is as follows:
[mysqld]
port = 3306
basedir=C:/software/mysql-5.7.21-winx64
datadir=C:/software/mysql-5.7.21-winx64/data
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysql]
default-character-set=utf8
Attention should be paid to this step: the installation path of MySQL is in the red box, and "/" instead of "\" is used between the folders, otherwise errors may occur in the following operations
After editing the my.ini file, put the my.ini file in the C:\software\mysql-5.7.21-winx64 directory
5. Open the cmd command window as an administrator and switch the directory to the bin directory of the MySQL installation directory
6. Execute the following statement to install MySQL
mysqld -install
After executing the command, the prompt: Service successfully installed. Indicates that the installation was successful
7. Execute the following statement to initialize MySQL
mysqld --initialize-insecure --user=mysql
After executing the command, the data directory will be generated in the MySQL installation directory and the root user will be created.
8. Execute the following command to start the mysql service
After execution, the following prompt will appear:
MySQL service is starting..
MySQL service has been started successfully.
9. After starting MySQL, the password of the root user is empty, set the password, the command is as follows:
When you need to enter the old password, because the old password is empty, just press Enter.
The MySQL5.7.21 decompressed version is installed.