Install MySQL 5.0 on Windows 10 at the same time 7 and mysql8 0 version

Posted by jets on Wed, 02 Mar 2022 07:01:55 +0100

Install MySQL 5.0 on Windows 10 at the same time 7 and MySQL 8 versions

1, Download two versions of MySQL

Enter the official website to download: https://www.mysql.com/
Click Downloads

Slide down to find MySQL Community Server

Directly enter the MySQL 8 version, and then download the compressed package version
Click the previous version in the upper right corner to download the MySQL 5 version

Also download the compressed version

2, Put the downloaded compressed package in the right place and decompress it

Note: unzip a version of MySQL 5 here, and then unzip version 8.0 when installing MySQL 8 later (otherwise it is easy to cause problems)

3, Configure environment variables

1. Right click my computer - > properties - > advanced system settings - > environment variables


2. Create a new variable
The variable value is the installation path of the corresponding mysql version


3. Find the Path variable and add two versions of bin at the end of the variable

add to
%MYSQL5_HOME%\bin
%MYSQL8_HOME%\bin

4, Install database

4.1 install MySQL 5 database
4.1.1 create my Ini configuration file

my.ini file content (double slash for directory segmentation)

[mysql]
# Set the default character set of mysql client
default-character-set=utf8
port = 3305
[mysqld]
# Set 3305 port
port = 3305
# Set mysql installation directory
basedir=D:\\MYSQL\\MYSQL5\\mysql-5.7.37-winx64
# Set the storage directory of mysql database data (generated automatically, otherwise an error may be reported)
datadir=D:\\MYSQL\\MYSQL5\\mysql-5.7.37-winx64\\data
# Maximum connections allowed
max_connections=10000
# Maximum number of connections allowed
max_user_connections=1000
# The character set used by the server defaults to the 8-bit encoded latin1 character set
character-set-server=utf8
# The default storage engine that will be used when creating new tables
default-storage-engine=INNODB

# Connection time
wait_timeout=31536000
interactive_timeout=31536000

4.1.2 generate Data folder
Open the cmd command prompt as an administrator and switch to the bin path of MySQL 5.
Enter the command: mysqld --initialize
After a while, it will regenerate a Data folder

Find the suffix General password, err.

@localhost is followed by a randomly generated password

4.1.3 install MySQL 5 service

Enter on the command line (name MYSQL5, and specify the default configuration file as the my.ini file just created)
mysqld --install MYSQL5 --defaults-file=D:\MYSQL\MYSQL5\mysql-5.7.37-winx64\my.ini

4.1.4 start MySQL 5 service

Enter at the command line
net start MYSQL5

4.1.5 log in to MYSQL5 and change the password

(1) Login input: mysql -u root -P 3305 -h localhost -p
Password entry Random password generated in rr file
(2) Modify password input: (the password is changed to 123456 here)

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';

(3) Refresh permissions: flush privileges;

4.2 installing MySQL 8 (the same as installing MySQL 5)
4.2.1 create my INI file

[mysql]
# Set the default character set of mysql client
default-character-set=utf8
port = 3308
[mysqld]
# Set 3308 port
port = 3308
# Set mysql installation directory
basedir=D:\\MYSQL\\MYSQL8\\mysql-8.0.28-winx64
# Set the storage directory of mysql database data (generated automatically, otherwise an error may be reported)
datadir=D:\\MYSQL\\MYSQL8\\mysql-8.0.28-winx64\\data
# Maximum connections allowed
max_connections=10000
# Maximum number of connections allowed
max_user_connections=1000
# The character set used by the server defaults to the 8-bit encoded latin1 character set
character-set-server=utf8
# The default storage engine that will be used when creating new tables
default-storage-engine=INNODB

# Connection time
wait_timeout=31536000
interactive_timeout=31536000


4.2.2 generate data folder
Open the cmd command prompt as an administrator and switch to the bin path of MySQL 8.
Enter the command: mysqld --initialize
After a while, it will regenerate a Data folder
Also found err file and find the corresponding generated random password

4.2.3 install MySQL 8 Service
Enter on the command line (name MYSQL8, and specify the default configuration file as the my.ini file just created)
mysqld --install MYSQL8 --defaults-file=D:\MYSQL\MYSQL8\mysql-8.0.28-winx64\my.ini

4.2.4 start MySQL 8 Service

Enter at the command line
net start MYSQL8

4.1.5 log in to MYSQL8 and change the password

(1) Login input: mysql -u root -P 3308 -h localhost -p
Password entry Random password generated in rr file
(2) Modify password input:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'lyl188338';

(3) Refresh permissions: flush privileges;

V View services


Then open the graphical interface, and both databases can be connected

Topics: MySQL