当前位置: 首页 > news >正文

MySQL多实例部署

1、软件包下载

//环境:一台rocky Linux虚拟机,并且做好的基本配置及时钟同步,使用Xshell连接

[root@mysql ~]# yum -y install tar lrzsz libncurses* libaio perl//将包文件拖进去
[root@mysql ~]# rz -E
rz waiting to receive.
[root@mysql ~]# ls
anaconda-ks.cfg  mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz

2、解压mysql包文件

[root@mysql ~]# tar -zxvf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@mysql local]# ln -sv mysql-5.7.37-linux-glibc2.12-x86_64/ mysql
'mysql' -> 'mysql-5.7.37-linux-glibc2.12-x86_64/'
[root@mysql local]# ll
total 0
drwxr-xr-x. 2 root root   6 May 16  2022 bin
drwxr-xr-x. 2 root root   6 May 16  2022 etc
drwxr-xr-x. 2 root root   6 May 16  2022 games
drwxr-xr-x. 2 root root   6 May 16  2022 include
drwxr-xr-x. 2 root root   6 May 16  2022 lib
drwxr-xr-x. 3 root root  17 Jul 10 19:27 lib64
drwxr-xr-x. 2 root root   6 May 16  2022 libexec
lrwxrwxrwx. 1 root root  36 Aug  3 23:56 mysql -> mysql-5.7.37-linux-glibc2.12-x86_64/
drwxr-xr-x. 9 root root 129 Aug  3 23:30 mysql-5.7.37-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root root   6 May 16  2022 sbin
drwxr-xr-x. 5 root root  49 Jul 10 19:27 share
drwxr-xr-x. 2 root root   6 May 16  2022 src

3、修改目录/usr/local/mysql的属主属组

[root@mysql local]# useradd -r -M -s /sbin/nologin mysql
[root@mysql local]# id mysql 
uid=996(mysql) gid=993(mysql) groups=993(mysql)[root@mysql local]# chown -R mysql.mysql mysql
[root@mysql local]# ll
total 0
drwxr-xr-x. 2 root  root    6 May 16  2022 bin
drwxr-xr-x. 2 root  root    6 May 16  2022 etc
drwxr-xr-x. 2 root  root    6 May 16  2022 games
drwxr-xr-x. 2 root  root    6 May 16  2022 include
drwxr-xr-x. 2 root  root    6 May 16  2022 lib
drwxr-xr-x. 3 root  root   17 Jul 10 19:27 lib64
drwxr-xr-x. 2 root  root    6 May 16  2022 libexec
lrwxrwxrwx. 1 mysql mysql  36 Aug  3 23:01 mysql -> mysql-5.7.22-linux-glibc2.12-x86_64/
drwxr-xr-x. 9 root  root  129 Aug  3 22:59 mysql-5.7.37-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root  root    6 May 16  2022 sbin
drwxr-xr-x. 5 root  root   49 Jul 10 19:27 share
drwxr-xr-x. 2 root  root    6 May 16  2022 src

4、配置MySQL环境变量

[root@mysql local]#  echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@mysql local]#  . /etc/profile.d/mysql.sh
[root@mysql local]# echo $PATH
/usr/local/mysql/bin:/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin//创建各实例数据存放目录
[root@mysql local]# mkdir -p /opt/data/{3306,3307,3308}
[root@mysql local]# chown -R mysql.mysql /opt/data/
[root@mysql local]# ll /opt/data/
total 0
drwxr-xr-x. 2 mysql mysql 6 Aug  3 23:10 3306
drwxr-xr-x. 2 mysql mysql 6 Aug  3 23:10 3307
drwxr-xr-x. 2 mysql mysql 6 Aug  3 23:10 3308

5、初始化各实例

初始化3306

[root@mysql ~]# mysqld --initialize --datadir=/opt/data/3306 --user=mysql
2024-08-03T15:59:39.140768Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2024-08-03T15:59:39.290523Z 0 [Warning] InnoDB: New log files created, LSN=45790
2024-08-03T15:59:39.311891Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2024-08-03T15:59:39.367520Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 6396fb3d-51b1-11ef-9f29-000c29d1dcca.
2024-08-03T15:59:39.368159Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2024-08-03T15:59:40.097249Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2024-08-03T15:59:40.097414Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2024-08-03T15:59:40.104003Z 0 [Warning] CA certificate ca.pem is self signed.
2024-08-03T15:59:40.249269Z 1 [Note] A temporary password is generated for root@localhost: u-Xpj-e0(&Er[root@mysql ~]# echo "u-Xpj-e0(&Er" > 3306_pass
[root@mysql ~]# cat 3306_pass 
u-Xpj-e0(&Er

初始化3307

[root@mysql ~]# mysqld --initialize --datadir=/opt/data/3307 --user=mysql
2024-08-03T16:05:34.713724Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2024-08-03T16:05:34.852024Z 0 [Warning] InnoDB: New log files created, LSN=45790
2024-08-03T16:05:34.874848Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2024-08-03T16:05:34.928396Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 3785442e-51b2-11ef-a8da-000c29d1dcca.
2024-08-03T16:05:34.929066Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2024-08-03T16:05:35.221373Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2024-08-03T16:05:35.221570Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2024-08-03T16:05:35.221942Z 0 [Warning] CA certificate ca.pem is self signed.
2024-08-03T16:05:35.404217Z 1 [Note] A temporary password is generated for root@localhost: jgpdj=3_R69w
[root@mysql ~]# echo "jgpdj=3_R69w" > 3307_pass
[root@mysql ~]# cat 3307_pass 
jgpdj=3_R69w

初始化3308

[root@mysql ~]# mysqld --initialize --datadir=/opt/data/3308 --user=mysql
2024-08-03T16:06:28.371318Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2024-08-03T16:06:28.791900Z 0 [Warning] InnoDB: New log files created, LSN=45790
2024-08-03T16:06:28.855382Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2024-08-03T16:06:28.909741Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 57b22a61-51b2-11ef-abbf-000c29d1dcca.
2024-08-03T16:06:28.910440Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2024-08-03T16:06:29.239286Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2024-08-03T16:06:29.239450Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2024-08-03T16:06:29.239839Z 0 [Warning] CA certificate ca.pem is self signed.
2024-08-03T16:06:29.391293Z 1 [Note] A temporary password is generated for root@localhost: pu>DiHCY>0NS
[root@mysql ~]# echo "pu>DiHCY>0NS" > 3308_pass
[root@mysql ~]# cat 3308_pass 
pu>DiHCY>0NS

6、配置配置文件

[root@mysql ~]# vim /etc/my.cnf    //在里面写入[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin[mysqld3306]
datadir = /opt/data/3306
port = 3306
socket = /tmp/mysql3306.sock
pid-file = /opt/data/3306/mysql_3306.pid
log-error=/var/log/3306.log[mysqld3307]
datadir = /opt/data/3307
port = 3307
socket = /tmp/mysql3307.sock
pid-file = /opt/data/3307/mysql_3307.pid
log-error=/var/log/3307.log[mysqld3308]
datadir = /opt/data/3308
port = 3308
socket = /tmp/mysql3308.sock
pid-file = /opt/data/3308/mysql_3308.pid
log-error=/var/log/3308.log

7、启动各实例

[root@mysql ~]# mysqld_multi start 3306
[root@mysql ~]# mysqld_multi start 3307
[root@mysql ~]# mysqld_multi start 3308
[root@mysql ~]# ss -antl
State     Recv-Q    Send-Q         Local Address:Port         Peer Address:Port    Process    
LISTEN    0         128                  0.0.0.0:22                0.0.0.0:*                  
LISTEN    0         128                     [::]:22                   [::]:*                  
LISTEN    0         80                         *:3308                    *:*                  
LISTEN    0         80                         *:3307                    *:*                  
LISTEN    0         80                         *:3306                    *:*          

8、初始化密码

3306

[root@mysql ~]# cat 3306_pass 
u-Xpj-e0(&Er[root@mysql ~]# mysql -uroot -p`u-Xpj-e0(&Er` -S /tmp/mysql3306.sock
-bash: command substitution: line 1: syntax error near unexpected token `&'
-bash: command substitution: line 1: `u-Xpj-e0(&Er'
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.37Copyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> set password = password('redhat');
Query OK, 0 rows affected, 1 warning (0.00 sec)

3307

[root@mysql ~]# cat 3307_pass 
jgpdj=3_R69w
[root@mysql ~]# mysql -uroot -p'jgpdj=3_R69w' -S /tmp/mysql3307.sock 
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.37Copyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> set password = password('redhat');
Query OK, 0 rows affected, 1 warning (0.00 sec)

3308

[root@mysql ~]# cat 3308_pass 
pu>DiHCY>0NS
[root@mysql ~]# mysql -uroot -p'pu>DiHCY>0NS' -S /tmp/mysql3308.sock 
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.37Copyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> set password = password('redhat');
Query OK, 0 rows affected, 1 warning (0.00 sec)

//mysql多实例部署成功

相关文章:

MySQL多实例部署

1、软件包下载 //环境:一台rocky Linux虚拟机,并且做好的基本配置及时钟同步,使用Xshell连接 [rootmysql ~]# yum -y install tar lrzsz libncurses* libaio perl//将包文件拖进去 [rootmysql ~]# rz -E rz waiting to receive. [rootmysql…...

云开发喝酒小程序3.6全新漂亮UI猜拳喝酒小程序 【已去除流量主】

云开发喝酒小程序3.6全新漂亮UI猜拳喝酒小程序 已去除流量主。UI特别漂亮,实属精品代码。 【已测】云开发喝酒小程序3.6漂亮UI猜拳喝酒小程序 已去除流量主。 云开发(serverless)小程序无需服务器,注册一个小程序就可以直接上线…...

图论进阶之路-最短路(Floyd)

时间复杂度:O(n^3) 使用场景:当需要得知任意两个点的最短距离以及其路径时使用 准备:需要两个矩阵 一个记录最短距离(D) 一个记录最短路径的最后一个结点(P) 其核心在于不断的判断越过中间…...

安装sqllab靶机之后,练习关卡报403 forbidden

解决办法: 在nginx的conf文件中添加上访问index.php vim /usr/local/nginx/conf/nginx.conf 保存退出 再重启一下nginx,就完成了。 ./nginx -s reload...

微信VX多开 免扫码 登录 互斥体 可视化 Exui v1.1 易语言源码附成品软件

UI设计: 1. EXUI界面库20240204 调用的模块: 1. wow64_hook_3.02.ec(压缩包内含) 2. 精易模块[v11.1.0].ec(自行下载) 更新日志: v1.1 2024年7月25日13:28:43 { 1. 有人反馈 设置了V…...

JavaEE 从入门到精通(一) ~ Maven

晚上好,愿这深深的夜色给你带来安宁,让温馨的夜晚抚平你一天的疲惫,美好的梦想在这个寂静的夜晚悄悄成长。 目录 前言 1.1 概念 什么是 Maven? Maven 的核心概念 1.2 maven依赖坐标 1.3 maven仓库 1.4 maven安装 1.5 mave…...

滚珠丝杆与丝杆支撑座:稳定性与精度的双重保障

丝杆支撑座是连接滚珠丝杆与电机的轴承,采用优质的轴承能确保支撑座与滚珠丝杆之间的刚性平衡。那么,滚珠丝杆搭连接杆支撑座有哪些优缺点呢? 正常情况下,丝杆支撑座能够提供稳定的支撑力,确保滚珠丝杆在复杂工况下保持…...

实验5-11 空心的数字金字塔

本题要求实现一个函数,输出n行空心的数字金字塔。 函数接口定义: void hollowPyramid( int n );其中n是用户传入的参数,为[1, 9]的正整数。要求函数按照如样例所示的格式打印出n行空心的数字金字塔,请注意,最后一行的…...

C#对象和类型

属性、方法、字段 字段和属性的区别 在C#中,字段(fields)和属性(properties)都是类的成员,它们提供了类存储数据的方式,但它们在用途和功能上有着明显的区别。 字段 字段通常用来存储类…...

免费分享一套SpringBoot+Vue图书(图书借阅)管理系统【论文+源码+SQL脚本】,帅呆了~~

大家好,我是java1234_小锋老师,看到一个不错的SpringBootVue图书(图书借阅)管理系统,分享下哈。 项目视频演示 【免费】SpringBootVue图书(图书借阅)管理系统 Java毕业设计_哔哩哔哩_bilibili 项目介绍 本论文阐述了一套先进的图书管理系…...

数据结构与算法--队列

文章目录 提要队列的定义队列的认识队列的应用队列的抽象数据类型队列的存储结构队列的链式存储结构与实现链队的进队和出队操作链队的数据类型初始化链队列入队操作出队操作队列的顺序存储结构与实现顺序队列的假溢出问题队列上溢循环队列循环队列取下一相邻单元下标运算队满与…...

<Qt> 常用控件

目录 一、控件概述 二、QWidget 核心属性 (一)QWidget的核心属性概览 1. enabled 2. geometry 3. WindowFrame的影响 4. windowTitle 5. window Icon 6. windowOpacity 7. cursor 8. font 9. toolTip 10. focusPolicy 11. styleSheet 三、…...

关于C/C++的编译、构建、CMake、x86_amd64等问题(自用)

被这些玩意整红温了 编译器版本 x86:编译器为x86版本,输出文件为x86。amd64_x86:编译器为amd64版本,输出文件为x86。amd64:编译器为amd64版本,输出文件为amd64。x86_amd64:编译器为x86版本&am…...

【设计模式】工厂模式详解

1.简介 工厂模式是一种创建型设计模式,通过提供一个接口或抽象类来创建对象,而不是直接实例化对象。工厂模式的主要思想是将对象的创建与使用分离,使得创建对象的过程更加灵活和可扩展。 工厂模式主要包括以下角色: 抽象工厂&a…...

【Spring Boot】用 Spring Security 实现后台登录及权限认证功能

用 Spring Security 实现后台登录及权限认证功能 1.引入依赖2.创建权限开放的页面3.创建需要权限验证的页面4.配置 Spring Security4.1 配置 Spring MVC4.2 配置 Spring Security 5.创建登录页面6.测试权限 1.引入依赖 使用前需要引入相关依赖,见以下代码&#xff…...

PHP开发【石头剪刀布小游戏】

石头剪刀布小游戏 玩法超级简单,你只需要在下面选择石头、剪刀或者布,然后提交,系统就会随机生成电脑的选择,告诉你最终的结果哦! 游戏规则: 如果你的选择和电脑一样,那么就是平局。如果你赢…...

(leetcode学习)42. 接雨水

给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。 示例 1: 输入:height [0,1,0,2,1,0,1,3,2,1,2,1] 输出:6 解释:上面是由数组 [0,1,0,2,1,0,1,3,2,1,2,1] 表…...

Python编程实例2

一、通过用户输入数字计算阶乘 # 获取用户输入的数字 num int(input("请输入一个数字: ")) factorial 1 # 查看数字是负数&#xff0c;0 或 正数 if num < 0:print("抱歉&#xff0c;负数没有阶乘") elif num 0:print("0 的阶乘为 1") e…...

排序算法:堆排序,golang实现

目录 前言 堆排序 代码示例 1. 算法包 2. 堆排序代码 3. 模拟程序 4. 运行程序 5. 从大到小排序 堆排序的思想 堆排序的实现逻辑 1. 构建最大堆 2. 排序 循环次数测试 假如 10 条数据进行排序 假如 20 条数据进行排序 假如 30 条数据进行排序 假设 5000 条数据…...

【网络安全入门】学习网络安全必须知道的77个网络基础知识

1、TCP/IP 协议的四层模型&#xff08;网络接口层、网络层、传输层、应用层&#xff09; TCP/IP 协议是互联网通信的基础&#xff0c;四层模型中&#xff0c;网络接口层负责与物理网络的连接&#xff1b;网络层主要处理 IP 数据包的路由和转发&#xff1b;传输层提供端到端的可…...

Chapter03-Authentication vulnerabilities

文章目录 1. 身份验证简介1.1 What is authentication1.2 difference between authentication and authorization1.3 身份验证机制失效的原因1.4 身份验证机制失效的影响 2. 基于登录功能的漏洞2.1 密码爆破2.2 用户名枚举2.3 有缺陷的暴力破解防护2.3.1 如果用户登录尝试失败次…...

业务系统对接大模型的基础方案:架构设计与关键步骤

业务系统对接大模型&#xff1a;架构设计与关键步骤 在当今数字化转型的浪潮中&#xff0c;大语言模型&#xff08;LLM&#xff09;已成为企业提升业务效率和创新能力的关键技术之一。将大模型集成到业务系统中&#xff0c;不仅可以优化用户体验&#xff0c;还能为业务决策提供…...

脑机新手指南(八):OpenBCI_GUI:从环境搭建到数据可视化(下)

一、数据处理与分析实战 &#xff08;一&#xff09;实时滤波与参数调整 基础滤波操作 60Hz 工频滤波&#xff1a;勾选界面右侧 “60Hz” 复选框&#xff0c;可有效抑制电网干扰&#xff08;适用于北美地区&#xff0c;欧洲用户可调整为 50Hz&#xff09;。 平滑处理&…...

抖音增长新引擎:品融电商,一站式全案代运营领跑者

抖音增长新引擎&#xff1a;品融电商&#xff0c;一站式全案代运营领跑者 在抖音这个日活超7亿的流量汪洋中&#xff0c;品牌如何破浪前行&#xff1f;自建团队成本高、效果难控&#xff1b;碎片化运营又难成合力——这正是许多企业面临的增长困局。品融电商以「抖音全案代运营…...

使用van-uploader 的UI组件,结合vue2如何实现图片上传组件的封装

以下是基于 vant-ui&#xff08;适配 Vue2 版本 &#xff09;实现截图中照片上传预览、删除功能&#xff0c;并封装成可复用组件的完整代码&#xff0c;包含样式和逻辑实现&#xff0c;可直接在 Vue2 项目中使用&#xff1a; 1. 封装的图片上传组件 ImageUploader.vue <te…...

【算法训练营Day07】字符串part1

文章目录 反转字符串反转字符串II替换数字 反转字符串 题目链接&#xff1a;344. 反转字符串 双指针法&#xff0c;两个指针的元素直接调转即可 class Solution {public void reverseString(char[] s) {int head 0;int end s.length - 1;while(head < end) {char temp …...

GitHub 趋势日报 (2025年06月08日)

&#x1f4ca; 由 TrendForge 系统生成 | &#x1f310; https://trendforge.devlive.org/ &#x1f310; 本日报中的项目描述已自动翻译为中文 &#x1f4c8; 今日获星趋势图 今日获星趋势图 884 cognee 566 dify 414 HumanSystemOptimization 414 omni-tools 321 note-gen …...

大模型多显卡多服务器并行计算方法与实践指南

一、分布式训练概述 大规模语言模型的训练通常需要分布式计算技术,以解决单机资源不足的问题。分布式训练主要分为两种模式: 数据并行:将数据分片到不同设备,每个设备拥有完整的模型副本 模型并行:将模型分割到不同设备,每个设备处理部分模型计算 现代大模型训练通常结合…...

《基于Apache Flink的流处理》笔记

思维导图 1-3 章 4-7章 8-11 章 参考资料 源码&#xff1a; https://github.com/streaming-with-flink 博客 https://flink.apache.org/bloghttps://www.ververica.com/blog 聚会及会议 https://flink-forward.orghttps://www.meetup.com/topics/apache-flink https://n…...

selenium学习实战【Python爬虫】

selenium学习实战【Python爬虫】 文章目录 selenium学习实战【Python爬虫】一、声明二、学习目标三、安装依赖3.1 安装selenium库3.2 安装浏览器驱动3.2.1 查看Edge版本3.2.2 驱动安装 四、代码讲解4.1 配置浏览器4.2 加载更多4.3 寻找内容4.4 完整代码 五、报告文件爬取5.1 提…...