系统版本 | 安装方式以及版本 |
---|---|
centos8 | mysql5.7(二进制安装) |
安装包添加环境变量以及属主等步骤省略,各路神仙都会
[root@clq ~]# mkdir /opt/data/{3306,3307,3308} -p [root@clq ~]# chown mysql.mysql /opt/data/*
[root@192 ~]# mysqld --initialize --datadir=/opt/data/3306 --user=mysql [root@192 ~]# mysqld --initialize --datadir=/opt/data/3307 --user=mysql [root@192 ~]# mysqld --initialize --datadir=/opt/data/3308 --user=mysql #分别保存3个mysql密码 [root@192 ~]# echo 'wxa+r_N6ooYu' > 3306 [root@192 ~]# echo 'faiuehfaowh' > 3307 [root@192 ~]# echo 'fuahfu' > 3308
Perl提供脚本语言(如sed和awk)的所有功能
[root@clq ~]# yum -y install perl
[root@clq ~]# dnf whatprovides libncurses.so.5 ncurses-compat-libs-6.1-7.20180224.el8.i686 : Ncurses compatibility libraries #查看哪个包提供仓库 : @System匹配来源:提供 : libncurses.so.5 [root@clq ~]# dnf -y install ncurses-compat-libs (兼容库)
[root@192 ~]# cat /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/mysql3306.pid log-error = /var/log/3306.log [mysqld3307] #必须是mysqld3307 不是mysql3307 datadir = /opt/data/3307 port = 3307 socket = /tmp/mysql3307.sock pid-file = /opt/data/3307/mysql3307.pid log-error = /var/log/3307.log [mysqld3308] datadir = /opt/data/3308 port = 3308 socket = /tmp/mysql3308.sock pid-file = /opt/data/3308/mysql3308.pid log-error = /var/log/3308.log
*前提必须指定套接字或者本地ip127.0.0.1进行连接
//分别进入mysql,依次更改密码即可
#mysqld_multi服务脚本复制到/etc/init.d/下 [root@mysql ~]# cp /usr/local/mysql/support-files/mysqld_multi.server /etc/init.d/mysqld_multi #修改脚本,系统脚本启动的时候会在新的终端重新加载加这一条会在bindir下找到mysqld_multi basedir=/usr/local/mysql bindir=/usr/local/mysql/bin export PATH=$bindir:$PATH systemctl daemon-reload 系统重新加载服务 开启: [root@mysql ~]# service mysqld_multi start 3306 [root@mysql ~]# service mysqld_multi start 3307 [root@mysql ~]# service mysqld_multi start 3308 自启动: [root@mysql ~]# chkconfig mysqld_multi on [root@mysql ~]#reboot [root@mysql ~]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port Process LISTEN 0 80 *:3306 *:* LISTEN 0 80 *:3307 *:* LISTEN 0 80 *:3308 *:*
#关闭单个mysql,用kill方式杀掉进程即可
以上就是MySQL多实例安装开机自启服务配置过程的详细内容,更多关于MySQL多实例安装开机自启服务配置的资料请关注脚本之家其它相关文章!