1. Download the database and configure environment variables

The default MySQL port number is 3306. You are advised to configure a non-default port number to avoid problems

1.1 websiteDownload the 5.7 and 8.0 packages

  • I downloaded5.7.238.0.23

1.2 Decompressing the package to a directory

  • Unzip the package to the directory you want to install, in this case, D:\develop\MySQL

1.3 Configuring System Variables

MYSQL5_HOME is added in the system variables and MYSQL8_HOME two variables, extract a variable’s value is your Path, then in the Path of the two bin added, after the completion of the save

2. Install MySQL8.0

2.1 Creating a Configuration File

Create the my.ini file in the root directory with the ANSI encoding, then edit the configuration file to save

[mysql]  
Mysql client default character set
default-character-set=utf8 
 
[mysqld]  
# set port
port = 3307

Set mysql installation directory
basedir=D:\develop\MySQL\mysql-8.0.23-winx64

Mysql > select * from 'mysql'
datadir=D:\develop\MySQL\mysql-8.0.23-winx64\data 

# Maximum number of connections allowed
max_connections=10000

# Maximum number of connections allowed
max_user_connections=1000

The default character set used by the server is the 8-bit latin1 character set
character-set-server=utf8  

The default storage engine to use when creating new tables
#default-storage-engine=MyISAM
default-storage-engine=InnoDB

# Connection time
wait_timeout=31536000
interactive_timeout=31536000
Copy the code

2.2 Initializing MySQL

Make sure there is no data folder in the root directory. If there is, delete it and then go to the bin directory

Perform mysqld — the initialize

  • If you executemysqld --initialize-insecureBy default, the created root does not have a password

After initialization, a data folder is automatically created in the root directory

If you don’t include -insecure, you’ll be assigned a random password. The password is in the XXX. Err file in the data directory:

Because of my default empty password, it is not displayed, otherwise it would be displayed at the end of this

2.3 Installing the MySQL Service

On the command line, type mysqld –install MYSQL80 (MYSQL80 is the service name, you can customize it, it must be added, because the default is MYSQL, if not, the two databases will conflict).

2.4 Starting the MySQL service

On the command line, enter net start MYSQL80 to start the MySQL8.0 service

If the command cannot be opened, as shown in the following figure:

There should be a problem with the service configuration. Open the system’s service configuration and find MYSQL80

Right click to view properties, it is obvious that this path is not correct.

But it doesn’t matter, we can change it manually

Successful startup!

2.5 Changing the Initial Password

Mysql -u root -p 3307 -p (-p indicates the port number, -p indicates the password, and -u indicates the user

Then change the password BY entering ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘123456’;

Finally, refresh the privileges and enter Flush PRIVILEGES

At this point, MySQL8 is installed successfully

3. Install MySQL5.7

Again, this is basically the same as installing MySQL8.0, with some subtle differences

3.1 Different port numbers

MySQL5.7 is more common for me, so I set it to the default port number 3306 and change the path as well

[mysqld] [mysqld] [mysqld] [mysqld] [mysqld] [mysqld] [mysqld Datadir =D: develop MySQL MySQL MySQL -5.7.23-winx64 datadir=D: develop MySQL MySQL -5.7.23-winx64 Max_user_connections =1000 # The default character set used by the server is the latin1 character set with 8-bit encoding Character-set-server =utf8 #default-storage-engine=MyISAM default-storage-engine=InnoDB # connection time wait_timeout=31536000 interactive_timeout=31536000Copy the code