当前位置:网站首页>Windows10 installs both MySQL 5 and MySQL 8

Windows10 installs both MySQL 5 and MySQL 8

2022-06-09 05:07:00 Mr. Wangchuang

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
 Insert picture description here
Slide down to find MySQL Community Server
 Insert picture description here
Direct entry yes MySQL8 edition , Then download the compressed version  Insert picture description here
Click on the previous version in the upper right corner , download MySQL5 edition
 Insert picture description here
Also download the compressed version
 Insert picture description here

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 )
 Insert picture description here

3、 ... and 、 Configure environment variables

1. Right click on my computer -> attribute -> Advanced system setup -> environment variable
 Insert picture description here
 Insert picture description here
2. New variable
The variable value is the corresponding mysql Installation path of version
 Insert picture description here
 Insert picture description here
3. find Path Variable , At the end of the variable , Add two versions of bin

add to
%MYSQL5_HOME%\bin
%MYSQL8_HOME%\bin
 Insert picture description here

Four 、 mount this database

4.1 install MySQL5 database
4.1.1 establish my.ini The configuration file
 Insert picture description here
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
 Insert picture description here
 Insert picture description here

Find the suffix .err The file of , Open find password password, There is usually a password .
 Insert picture description here
@localhost The following is the randomly generated password
 Insert picture description here
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
 Insert picture description here
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
 Insert picture description here
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
 Insert picture description here
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;
 Insert picture description here

5、 ... and . View service

 Insert picture description here
Then open the graphical interface. Both databases can be connected
 Insert picture description here

原网站

版权声明
本文为[Mr. Wangchuang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203021434598071.html