最近在學習mycat原始碼,有單台雲主機上要跑多個例項的需求,參考了以下的文章
4.修改my.cnf
vim /usr/local/mysql/etc/my.cnf
注釋以下內容
[client]
password = your_password
port = 3306
socket = /tmp/mysql.sock
新增以下
[mysqld_multi]
mysqld=/usr/local/mysql/bin/mysqld_safe
mysqladmin=/usr/local/mysql/bin/mysqladmin
user=root
password=wxm123456
修改[mysqld1]
port = 3306
socket = /tmp/mysql3306.sock
pid-file = /usr/local/mysql/data3306/mysql.pid
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data3306
log_error = /usr/local/mysql/3306_error.log
[mysqld2]
port = 3307
socket = /tmp/mysql3307.sock
pid-file = /usr/local/mysql/data3307/mysql.pid
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data3307
log_error = /usr/local/mysql/3307_error.log
[mysqld3]
port = 3308
socket = /tmp/mysql3308.sock
pid-file = /usr/local/mysql/data3308/mysql.pid
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data3308
log_error = /usr/local/mysql/3308_error.log
5.不需要密碼直接登入後,配置mysql訪問許可權
mysql -s /tmp/mysql3306.sock -p 3306 -uroot -p
mysql -s /tmp/mysql3307.sock -p 3307 -uroot -p
mysql -s /tmp/mysql3308.sock -p 3308-uroot -p
mysql> set password=password('wxm123456');
mysql> grant all on *.* to'root'@'%' identified by 'wxm123456';
mysql> flush privileges;
6.啟動所有mysql例項
mysqld_multi --defaults-file=/usr/local/mysql/etc/my.cnf start 1,2,3
7.啟動單個mysql例項
mysqld_multi --defaults-file=/usr/local/mysql/etc/my.cnf start 1
mysqld_multi --defaults-file=/usr/local/mysql/etc/my.cnf start 2
mysqld_multi --defaults-file=/usr/local/mysql/etc/my.cnf start 3
8.檢視所有例項狀態
#mysqld_multi --defaults-file=/usr/local/mysql/etc/my.cnf report 1,2,3
reporting mysql servers
mysql server from group: mysqld1 is running
mysql server from group: mysqld2 is running
mysql server from group: mysqld3 is running
9.停止所有例項
ps -ef | grep mysql | awk '' | xargs kill -9
10.停止單個例項
ps -ef | grep data3306 | awk '' | xargs kill -9
ps -ef | grep data3307 | awk '' | xargs kill -9
ps -ef | grep data3308 | awk '' | xargs kill -9
mysql單機多例項 MYSQL單機多例項
一 建立安裝目錄 mkdir usr local mysql s 5.6.32 mkdir usr local mysql m 5.6.32 wget tar zxv f mysql 5.6.32.tar.gz 二 編譯命令 1 主編引數 cmake dcmake install prefix da...
MySQL 單機多例項
關於mysql 單機多例項的優缺點等介紹具體可以知乎一下或參考mysql單機多例項配置 實現單機多例項可以通過docker輕鬆做到,這裡主要是分享使用自帶工具mysqld multi的過程及兩個坑點 系統 ubuntu 16.04lts xenial 版本 percorna server 5.7.2...
mysql單機多例項
在資料庫伺服器上,可以架構多個mysql伺服器,進行單機多例項的讀寫分離 可以通過mysqld multi來進行多例項的管理,mysqld multi是用perl寫的指令碼,原理是通過mysql admin來進行多個資料庫的操作 多例項的配置檔案也有點不同,可以看作是多個mysql配置的集合 mys...