1. Download address: https://dev.mysql.com/downloads/mysql/5.7.html#downloads
Click directly on the download item
After downloading:
2. You can put the decompressed content in a directory, mine is the following directory (if you put it on the C drive, it may involve permission issues when modifying the ini file, and then I will put it on the D drive):
D:\MySQL\MySQL Server 5.7.22
As shown below: There is no data directory and ini file in the compressed file at this time
3. Create a new my.ini file in the D:\MySQL\MySQL Server 5.7.22 directory and copy the following content
[mysqld]
port = 3306
basedir=D:\MySQL\MySQL Server 5.7.22
datadir=D:\MySQL\MySQL Server 5.7.22\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
Note: The red part in the content is the mysql directory, the path in the previous part
4. Configure the environment variables below:
Computer Properties - "Advanced System Settings -"
Click on Environment Variables
Create a new variable name in the system variable section: MYSQL_HOME, variable value: D:\MySQL\MySQL Server 5.7.22
5. MySQL installation process:
run cmd as administrator
Enter the following directory: D:\MySQL\MySQL Server 5.7.22\bin
Run the command: mysqld --initialize (the data directory will be generated at this time)
run mysqld -install (install)
Run net start mysql (start mysql service)
The MySQL service can be seen in the task manager
6. Set the root account password:
Add a line to skip-grant-tables under [mysqld] in the my.ini file (MySQL configuration file)
Then restart the MySQL service in the task manager
After restarting the MqSQL service, run mysql -uroot -p to successfully log in to mysql
Then update the password of the root account to 'root'
命令:update mysql.user set authentication_string=password("root") where user="root";
Then enter flush privileges; (refresh account information)
Execute quit or ctrl+Z to exit
Then delete the skip-grant-tables line just added in the my.ini file, save it, and then restart the MySQL service
Then run mysql -uroot -proot to log in with root user name and root password