1. Download
Official website address: (Community Edition) https://downloads.mysql.com/archives/community/
In the download interface, select the 64-bit zip. This is the green version and the msi image installation board. Don’t make a mistake.
Download and unzip
2. Unzip and install
It is found that there is no data directory and my.ini file in the mysql root directory. It doesn't matter. The system will automatically create a data directory when initializing mysql. We only need to create a my.ini file.
Create a new text document and save it as a my.ini file. The contents are:
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
#设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=F:\mysql-5.7.24-winx64
# 设置mysql数据库的数据的存放目录
datadir=F:\mysql-5.7.24-winx64\data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
The installation directory and storage directory are set according to your own needs.
Search cmd to find the command prompt, right-click and run as administrator, enter the bin directory of the installation directory, and enter the following command:
mysqld --initialize --user=mysql --console
In the printed log, there will be an initial password, record it and use it to log in. In this way, the installation and the generation of the data folder and related files are completed.
Enter the following command to install mysql:
mysqld --install mysql
Display Service successfully installed. Indicates successful installation.
3. Log in
Enter the following command to start mysql:
net start mysql
Enter the following command to log in to mysql: mysql -u root -p. The initial password is mysqld --initialize --user=mysql --console
the log we printed during execution.
4. Change the initial password
Modify the mysql login password and enter the following command (note the semicolon)
set password=password('新密码');
After modification, remember to update and enter:
flush privileges;
5. Configure environment variables
In order to facilitate subsequent operations, we need to configure the environment variables of mysql. Select Path and add our bin directory to the environment variables.
Then add in path:
;%MySql%\bin
This article refers to: Download and installation of mysql5.7 version on windows10