1. Download mysql-5.7.32-winx64.zip from the official website
2. Unzip to the file D:\DiskSoftware\MySQL, of course other disks are also available, and configure environment variables
Right click on Computer -> Properties -> Advanced System Settings -> Environment Variables -> New Variable
Add %MySQL_HOME%\bin after the system variable path
3. Create an empty data folder (used to store data) in the D:\DiskSoftware\MySQL\mysql-5.7.32-winx64 directory, and create a new text file my.ini, put the following code into my.ini In the file:
[mysql]
default-character-set=utf8
[mysqld]
#Set port number
port=3306
character_set_server=utf8
#Installation directory
basedir=D:/DiskSoftware/MySQL/mysql-5.7.32-winx64
#Set the database data storage directory
datadir =D:/DiskSoftware/MySQL/mysql-5.7.32-winx64/data
#The maximum number of connections allowed
max_connections=200
#The server uses the default character set
character_set_server=utf8
#Use the default storage engine when creating a new table
default-storage-engine=INNODB
explicit_defaults_for_timestamp=true
4. Run cmd.exe as an administrator and enter the D:\DiskSoftware\MySQL\mysql-5.7.32-winx64\bin directory
5. Initialize the database Execute the command: mysqld --initialize --user=mysql --console
After execution, be sure to remember the password behind localhost, which will be used to log in later.
6. Install the service execution command: mysqld install
7. Start the service and execute the command: net start mysql
8. Run mysql to execute the command: mysql -uroot -p
Enter the localhost password from step 5
9. You can change the password after logging in, execute the command: set password for root@localhost=password('你的密码');