Article directory
1. Download MySQL 5.7
First, you need to go to the MySQL official website to download the installation file of MySQL 5.7, and select the version suitable for your system to download.
If the download is too slow, here is a Baidu network disk download , extraction code: 4kmk
2. Install MySQL 5.7
1. Unzip the installation file
Unzip the downloaded compressed file to a specified directory, for example: D:\mysql-5.7.
2. Configure my.ini file
Create a my.ini file in the MySQL installation directory and fill in the following content:
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
# 设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=D:\mysql-5.7
# 设置mysql数据库的数据的存放目录
datadir=D:\mysql-5.7\data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
3. Initialize the MySQL database
Open the command line window as an administrator, enter the bin directory under the MySQL installation directory, and execute the following command:
mysqld --initialize --console
This command will initialize the MySQL database, generating a random root password. Please record this random root password, which will be used later to change the password
4. Install the MySQL service
Execute the following command in the command line window to install the MySQL service:
mysqld install
5. Start the MySQL service
Execute the following command in the command line window to start the MySQL service:
net start mysql
At this point, the MySQL service has been successfully started.
3. Modify the root password
MySQL 5.7 generates a random password by default, you need to modify the root user's password. The password can be changed using the following command:
1. Open the MySQL command line window
Enter the following command in the command line window to open the MySQL command line window:
mysql -u root -p
At this point, you need to enter the random password you just generated.
2. Modify the root password
Enter the following command in the MySQL command line window to change the root password:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new_password';
Among them, new_password is the new password.
Fourth, connect to the MySQL database
Enter the following command in the command line window to connect to the MySQL database:
mysql -u root -p
At this point, enter the new password to successfully connect to the MySQL database.
The above are the complete steps to install MySQL 5.7 on Windows system.
5. Set the boot to start automatically
Enter the following command in the command line window to set the MySQL service to start automatically at boot:
sc config mysql start= auto
After execution, it will prompt "SUCCESS" to indicate that the setting is successful. Now, the MySQL service has been registered as a Windows service and has been set to start automatically at boot. You can use the service manager to check whether the MySQL service has been started and whether it has been set to start automatically at boot.