MySQL8单台机器部署多实例

MySQL8单台机器多实例启动

一、本地环境配置

先安装单个mysql,安装过程请参考CentOS7 安装MySQL8

二、配置第二个实例
进入已安装好的MySQL目录复制一份新的
[root@gone local]# cp mysql mysql2 -R

在这里插入图片描述

为当前的安装包添加配置文件
[root@gone local]# vim /etc/my3307.cnf
[mysqld]
basedir=/usr/local/mysql2
datadir=/usr/local/mysql2/data
port=3307
socket=/tmp/mysql3307.sock
mysqlx_port=33070
mysqlx_socket=/tmp/mysqlx33070.sock
进入到mysql2目录执行命令启动mysql
[root@gone mysql2]# bin/mysqld --defaults-file=/etc/my3307.cnf --user=mysql
2023-02-14T08:25:59.967577Z 0 [System] [MY-010116] [Server] /usr/local/mysql2/bin/mysqld (mysqld 8.0.25) starting as process 91886
2023-02-14T08:26:00.090328Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-02-14T08:26:00.729129Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-02-14T08:26:00.858054Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33070, socket: /tmp/mysqlx33070.sock
2023-02-14T08:26:00.905405Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-02-14T08:26:00.905871Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-02-14T08:26:00.938212Z 0 [System] [MY-010931] [Server] /usr/local/mysql2/bin/mysqld: ready for connections. Version: '8.0.25'  socket: '/tmp/mysql3307.sock'  port: 3307  MySQL Community Server - GPL
查看是否有端口为3307的mysql服务
[root@gone local]# netstat -an|grep LISTEN

在这里插入图片描述

连接mysql 服务验证
[root@gone ~]# mysql -u root -p -S /tmp/mysql3308.sock
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.25 MySQL Community Server - GPL

Copyright (c) 2000, 2021, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.11 sec)

mysql> 
停止mysql 服务
[root@gone mysql2]# bin/mysqladmin -u root -p -S /tmp/mysql3307.sock  shutdown
查看是否还存在3307端口

在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值