系統(tǒng)版本 | 安裝方式以及版本 |
---|---|
centos8 | mysql5.7(二進制安裝) |
安裝包添加環(huán)境變量以及屬主等步驟省略,各路神仙都會
[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 #修改腳本,系統(tǒng)腳本啟動的時候會在新的終端重新加載加這一條會在bindir下找到mysqld_multi basedir=/usr/local/mysql bindir=/usr/local/mysql/bin export PATH=$bindir:$PATH systemctl daemon-reload 系統(tǒng)重新加載服務 開啟: [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多實例安裝開機自啟服務配置的資料請關注腳本之家其它相關文章!