MySQL多实例部署

本文详细介绍了如何在一台服务器上部署多个MySQL实例,包括3306、3307和3308端口的配置,涉及安装MySQL、配置my.cnf文件、初始化、启动实例、修改密码及设置开机自启等关键步骤。
摘要由CSDN通过智能技术生成

 

[root@localhost ~]# useradd -r -M -s /sbin/nologin mysql  //创建用户

[root@localhost ~]# cd /usr/src/
[root@localhost src]# tar -xf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz  -C /usr/local/  //解压软件包、

[root@localhost src]# cd /usr/local/
[root@localhost local]# mv mysql-5.7.37-linux-glibc2.12-x86_64/ mysql
[root@localhost local]# chown -R mysql.mysql mysql/  //修改权限

[root@localhost local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh 
[root@localhost local]# source /etc/profile.d/mysql.sh 
[root@localhost local]# which mysql
/usr/local/mysql/bin/mysql  //配置环境变量

[root@localhost mysql]# ln -s /usr/local/mysql/include/ /usr/include/mysql  //配置include软连接
[root@localhost mysql]# vim /etc/ld.so.conf.d/mysql.conf
[root@localhost mysql]# cat /etc/ld.so.conf.d/mysql.conf   //配置lib库
/usr/local/mysql/lib
[root@localhost mysql]# vim /etc/man_db.conf   //添加man文档
MANDATORY_MANPATH                       /usr/local/mysql/man

#创建数据库目录
[root@localhost ~]# mkdir -p /opt/data/{3306,3307,3308}
[root@localhost ~]# chown -R mysql.mysql /opt/data/
[root@localhost ~]# cd /opt/data/
[root@localhost data]# ll
总用量 0
drwxr-xr-x. 2 mysql mysql 6 7月   2 11:37 3306
drwxr-xr-x. 2 mysql mysql 6 7月   2 11:37 3307
drwxr-xr-x. 2 mysql mysql 6 7月   2 11:37 3308

 

配置多实例部署

3306初始化

[root@localhost ~]# mysqld --initialize --user=mysql --datadir=/opt/data/3306
2022-07-02T00:39:07.431121Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-07-02T00:39:07.703358Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-07-02T00:39:07.831924Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-07-02T00:39:07.952119Z 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: 8737c75c-f9b8-11ec-a29d-000c29d84f4a.
2022-07-02T00:39:07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值