Several MySQL database services of different versions are installed in super simple Win10 (currently 5.7 and 8.0.26)

Posted by electricblue on Mon, 13 Dec 2021 09:30:08 +0100

Several MySQL database services of different versions are installed in super simple Win10 (currently 5.7 and 8.0.26)

1, MySQL 8 0 installation package download?

1. Official website

Download address: https://downloads.mysql.com/archives/community/
Download the following versions:

2. Baidu cloud:

Link: https://pan.baidu.com/s/198TCAMFWc6h3F7oTHYvlXA
Extraction code: 8ipr

2, Installation steps

1. Unzip to the location you want to install

Unzip as follows: I changed the folder name myself (don't change it)
Custom path: avoid Chinese paths or special characters

2. Configuration file my ini

Please put my first The INI configuration file is placed in the bin directory
The code is as follows:

[mysqld]
# Set 3306 port
port=3307
# Set the mysql installation directory (compressed package decompression path)
basedir=D:\Programming\Install\Database\MySQL\mysql-8.0.26-winx64-config
# Set the storage directory of mysql database data
datadir=D:\Programming\Install\Database\MySQL\mysql-8.0.26-winx64-config\data
# Maximum connections allowed
max_connections=200
# Number of connection failures allowed. This is to prevent someone from trying to attack the database system from the host
max_connect_errors=10
# The character set used by the server is UTF8 by default
character-set-server=utf8mb4
# The default storage engine that will be used when creating new tables
default-storage-engine=INNODB
# The "mysql_native_password" plug-in authentication is used by default
default_authentication_plugin=mysql_native_password
[mysql]
# Set the default character set of mysql client
default-character-set=utf8mb4
[client]
# Set the default port used by mysql client when connecting to the server
port=3307
default-character-set=utf8mb4

Note: Please note whether the port is occupied. Set port=3307 here

3. Install MySQL 8 0.26 services

1 first: run cmd with administrator privileges and go to the decompression directory

Execute to the extracted folder directory (cmd command example):
If I want to go to D: \ programming \ install \ database \ MySQL \ mysql-8.0 on disk D 26-winx64-config
You must first enter the drive letter: D:
Then go to the corresponding D disk
Then jump according to the above method
cd D:\Programming\Install\Database\MySQL\mysql-8.0.26-winx64-config

2: Execute the following cmd command (see the figure)

1. Install mysql service

——The service here is named MySQL8026 for distinguishing. Install the specified my INI file mysqld service

bin\mysqld install MySQL8026 --defaults-file="D:\Programming\Install\Database\MySQL\mysql-8.0.26-winx64-config\my.ini"

2.mysql initialization

bin\mysqld --initialize --console

After execution, the output will contain the initial default password of mysql, which will be copied and saved later.

3. Start mysql service

net start MySQL8026

4. Modify the new mysql configuration

1. Change password

Note: the current mysql is executed under the bin directory, otherwise an error will be reported as follows (which mysql is logged in cannot be distinguished):

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Execution:

bin\mysql -u root -p       #Execute login
#Perform password change
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'CheerOn';
Query OK, 0 rows affected (0.01 sec)
2. Authorize root to access via ip (remote)

Set the Host to the wildcard% (as needed)

#The '%' is set by the Host to allow remote access
update mysql.user set host='%' where user='root';
#After modifying the Host, remember to execute flush privileges to make the configuration take effect immediately
flush privileges;


If you make a mistake in one step, resulting in failure and don't want to change it, run the command prompt as an administrator to delete the service (caution, this is directly deleted), and then enter sc delete mysql
mysql here is the mysql name in your service (some may be mysql 8026, or others).

summary

1. Summary of two figures without words:

First put my The INI configuration file is placed in the bin directory
All execute commands (cmd administrator):

#1. Install the mysqld service of the specified configuration file
bin\mysqld install MySQL8026 --defaults-file="D:\Programming\Install\Database\MySQL\mysql-8.0.26-winx64-config\my.ini"
#2. Service initialization
bin\mysqld --initialize --console
#3. Start the database service
net start MySQL8026
#4. Login
bin\mysql -u root -p
#5. Change password
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'CheerOn';
#6. Authorize root to access via ip (remote)
#The '%' is set by the Host to allow remote access
update mysql.user set host='%' where user='root';
#After modifying the Host, remember to execute flush privileges to make the configuration take effect immediately
flush privileges;

As shown below:


to be finished!!!

2. Set Host to wildcard% reason

The Host column specifies the IP used to allow users to log in, such as user = root Host = 192.168 1.1. This means that the root user can only pass 192.168 1.1 client to access. user=root Host=localhost, which means it can only be accessed through the local client. And% is a wildcard if Host = 192.168 1.%, it means that as long as the IP address is prefixed with "192.168.1." All clients can connect. If Host =%, all IPS have connection permissions.

Note: in the production environment, you can't set the host to% in order to save trouble. This will cause security problems. The specific settings can be set according to the IP of the production environment;
The '%' is set by the Host to allow remote access.
5. After modifying the host, remember to execute flush privileges to make the configuration take effect immediately

Topics: Database MySQL