Windows systems install and start multiple versions of MySQL at the same time


Install different versions of MySQL on the same Windows. This means that the environment is clean and MySQL has not been installed. If you have installed it, please search on Baidu first, uninstall it cleanly, and then install it. I installed versions 8.0 and 5.7. The versions can be changed by yourself
.

1. Install MySQL8.0

1.0 Download MySQL8.0 version

Download URL: https://dev.mysql.com/downloads/mysql/
Insert image description here
After downloading, decompress it in your own target directory

1.1 Configure configuration file

Create a my.ini file in the root directory of MySQL and configure it.
Insert image description here
Note: '/' should be used in the path, and '\' will trigger the escape operation

[client]    #客户端设置,即客户端默认的连接参数
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
 
#默认编码
default-character-set = utf8mb4
 
[mysql]    #客户端设置
#MySQL 提示符配置
#用户名@主机名+mysql版本号+数据库名

# 设置mysql客户端默认字符集
default-character-set = utf8mb4
 
[mysqld]    #服务端基本设置
# 默认连接端口
port=3306
 
# MySQL安装根目录的路径 
basedir=E:/sdl/tool/mysql-8.0.32-winx64
 
# MySQL服务器数据目录的路径
datadir=E:/sdl/tool/mysql-8.0.32-winx64/data
 
# 允许最大连接数
max_connections=200
 
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
 
#服务端默认编码
character_set_server = utf8mb4
 
#在创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
 
# 配置时区
default-time_zone='+8:00'
explicit_defaults_for_timestamp=true

1.2 Registration service

After the configuration file is configured, register and start the service,
enter the bin directory and execute the following content

# 注册服务
mysqld install
# 初始化mysql信息
mysqld --initialize --console

Insert image description here
After initialization, the root directory will generate a data folder, and
the console will print the MySQL initial password information

1.3 Change password

Start service

net start mysql

Login to MySQL

mysql -uroot -p

Enter the initial password to enter the system

Change the root account password to 123456

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

Just link the link tool

2. Install MySQL5.7

2.0 Download MySQL5.7 version

Download address: https://downloads.mysql.com/archives/community/

Insert image description here
Unzip after downloading

2.1 Configure configuration file

Create the my.ini configuration file in the mysql root directory
Insert image description here
Note: The port number should be distinguished from the port number of another MySQL service. Use '/' in the path

[Client]
#设置3307端口
port = 3307
[mysqld]
#设置3307端口
port = 3307
# 设置mysql的安装目录
basedir=E:/sdl/tool/mysql-5.7.21-winx64
# 设置mysql数据库的数据的存放目录
datadir=E:/sdl/tool/mysql-5.7.21-winx64/data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
log-bin=mysql-bin
server-id=1
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8

2.2 Registration service

After the configuration file is configured, register and start the service,
enter the bin directory and execute the following content

# 注册服务 (默认注册名是MySQL,  新注册的这个服务要与之前的服务名区分开)
mysqld install mysql5.7
# 初始化mysql信息
mysqld --initialize --console

Same as the previous steps, the
root directory will generate a data folder after initialization, and
the console will print the MySQL initial password information

2.3 Start the service and change the password

Start service

# 根据服务名启动服务
net start mysql5.7

Login to MySQL

mysql -uroot -p

Enter the initial password to enter the system

Change the root account password to 123456

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

Just link the link tool

Guess you like

Origin blog.csdn.net/weixin_44931584/article/details/129122663