Windows10 At the same time to install MySQL5.7 and MySQL8 edition
One 、 Download two versions of MySQL
Go to the official website to download :https://www.mysql.com/
Click on Downloads
Slide down to find MySQL Community Server
Direct entry yes MySQL8 edition , Then download the compressed version 
Click on the previous version in the upper right corner , download MySQL5 edition 
Also download the compressed version 
Two 、 Put the downloaded compressed package in the appropriate location and decompress it
Be careful : Here, unzip a MySQL5 edition , Install later MySQL8 Decompress when 8.0 edition ( Otherwise, it's easy to go wrong )
3、 ... and 、 Configure environment variables
1. Right click on my computer -> attribute -> Advanced system setup -> environment variable 

2. New variable
The variable value is the corresponding mysql Installation path of version 

3. find Path Variable , At the end of the variable , Add two versions of bin
add to %MYSQL5_HOME%\bin%MYSQL8_HOME%\bin
Four 、 mount this database
4.1 install MySQL5 database
4.1.1 establish my.ini The configuration file 
my.ini The contents of the document ( Directory segmentation uses double slashes )
[mysql]
# Set up mysql Client default character set
default-character-set=utf8
port = 3305
[mysqld]
# Set up 3305 port
port = 3305
# Set up mysql Installation directory
basedir=D:\\MYSQL\\MYSQL5\\mysql-5.7.37-winx64
# Set up mysql Database data storage directory ( Automatic generation , Otherwise, it may be wrong )
datadir=D:\\MYSQL\\MYSQL5\\mysql-5.7.37-winx64\\data
# Maximum connections allowed
max_connections=10000
# The maximum number of connections allowed
max_user_connections=1000
# The character set used by the server defaults to 8 Bit coded latin1 Character set
character-set-server=utf8
# The default storage engine that will be used when creating a new table
default-storage-engine=INNODB
# Connection time
wait_timeout=31536000
interactive_timeout=31536000
4.1.2 Generate Data Folder
Open as administrator cmd Command prompt , Switch to MySQL5 Of bin Under the path .
Enter the command :mysqld --initialize
Wait a while , It will regenerate a Data Folder 

Find the suffix .err The file of , Open find password password, There is usually a password .
@localhost The following is the randomly generated password 
4.1.3 install MySQL5 service
Enter at the command line ( The name is MYSQL5, also Specify that the default configuration file is the one just created my.ini file )mysqld --install MYSQL5 --defaults-file=D:\MYSQL\MYSQL5\mysql-5.7.37-winx64\my.ini
4.1.4 Turn on MySQL5 service
Enter at the command line net start MYSQL5
4.1.5 Sign in MYSQL5, And change the password
(1) Login input :mysql -u root -P 3305 -h localhost -p
Password input .err The random password generated in the file
(2) Modify password input :( Here the password is changed to 123456)
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
(3) Refresh the permissions :flush privileges;
4.2 install MySQL8( And installation MySQL5 Empathy )
4.2.1 establish my.ini file
[mysql]
# Set up mysql Client default character set
default-character-set=utf8
port = 3308
[mysqld]
# Set up 3308 port
port = 3308
# Set up mysql Installation directory
basedir=D:\\MYSQL\\MYSQL8\\mysql-8.0.28-winx64
# Set up mysql Database data storage directory ( Automatic generation , Otherwise, it may be wrong )
datadir=D:\\MYSQL\\MYSQL8\\mysql-8.0.28-winx64\\data
# Maximum connections allowed
max_connections=10000
# The maximum number of connections allowed
max_user_connections=1000
# The character set used by the server defaults to 8 Bit coded latin1 Character set
character-set-server=utf8
# The default storage engine that will be used when creating a new table
default-storage-engine=INNODB
# Connection time
wait_timeout=31536000
interactive_timeout=31536000
4.2.2 Generate data Folder
Open as administrator cmd Command prompt , Switch to MySQL8 Of bin Under the path .
Enter the command :mysqld --initialize
Wait a while , It will regenerate a Data Folder
Find the same .err file , Find the corresponding generated random password 
4.2.3 install MySQL8 service
Enter at the command line ( The name is MYSQL8, also Specify that the default configuration file is the one just created my.ini file )mysqld --install MYSQL8 --defaults-file=D:\MYSQL\MYSQL8\mysql-8.0.28-winx64\my.ini
4.2.4 Turn on MySQL8 service
Enter at the command line net start MYSQL8
4.1.5 Sign in MYSQL8, And change the password
(1) Login input :mysql -u root -P 3308 -h localhost -p
Password input .err The random password generated in the file
(2) Modify password input :
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'lyl188338';
(3) Refresh the permissions :flush privileges;
5、 ... and . View service

Then open the graphical interface. Both databases can be connected 





![[django learning notes - 12]: database operation](/img/d8/2c4b6c036532c213477754b6f9758e.png)



