mysql單伺服器啟動多個例項實際有兩種方式
第一種方式就是使用mysql mysqld_multi
第二種方式就是分別使用不同的目錄埠啟動不同的例項
第一種方式:
1、資料庫例項目錄
data3306
data3307
data3308
2、建立例項
/usr/local/mysql//scripts/mysql_install_db –basedir=/usr/local/mysql/ –datadir=/usr/local/mysql/data3306 –user=mysql
/usr/local/mysql//scripts/mysql_install_db –basedir=/usr/local/mysql/ –datadir=/usr/local/mysql/data3307 –user=mysql
/usr/local/mysql//scripts/mysql_install_db –basedir=/usr/local/mysql/ –datadir=/usr/local/mysql/data3308 –user=mysql
3、修改my.cnf檔案修改部分
[mysqld_multi]
mysqld = /usr/local/mysql//bin/mysqld
mysqladmin = /usr/local/mysql//bin/mysqladmin
user = root
password = 123456
[mysqld3306]
port = 3306
socket = /usr/local/mysql/mysqld3306.sock
pid-file = /usr/local/mysql/mysqld3306.pid
basedir = /usr/local/mysql/
datadir = /usr/local/mysql/data3306
[mysqld3307]
port = 3307
socket = /usr/local/mysql/mysqld3307.sock
pid-file = /usr/local/mysql/mysqld3307.pid
basedir = /usr/local/mysql/
datadir = /usr/local/mysql/data3307
[mysqld3307]
port = 3307
socket = /usr/local/mysql/mysqld3308.sock
pid-file = /usr/local/mysql/mysqld3308.pid
basedir = /usr/local/mysql/
datadir = /usr/local/mysql/data3308
4、啟動資料庫
mysqld_multi –defaults-file=/etc/mysql/my.cnf start 3306
mysqld_multi –defaults-file=/etc/mysql/my.cnf start 3307
mysqld_multi –defaults-file=/etc/mysql/my.cnf start 3308
5、登入資料庫修改root密碼
mysql -s /usr/local/mysql/mysqld3306.sock
mysql -s /usr/local/mysql/mysqld3307.sock
mysql -s /usr/local/mysql/mysqld3308.sock
use mysql
update user set password=password('123456') where user=』root』;
flush privileges;
6、關閉資料庫
mysqld_multi –defaults-file=/etc/mysql/my.cnf stop 3306
mysqld_multi –defaults-file=/etc/mysql/my.cnf stop 3307
mysqld_multi –defaults-file=/etc/mysql/my.cnf stop 3308
7、全部啟動/關閉
mysqld_multi –defaults-file=/etc/mysql/my.cnf start 3306-3308
mysqld_multi –defaults-file=/etc/mysql/my.cnf stop 3306-3308
第二種方式:
1,建立目錄
data3307
data3308
2,分別新增配置未見my.cnf
並修改裡面相關的引數
3.進行系統表初始化也可以從現有的複製過來一會
/usr/local/mysql//scripts/mysql_install_db –basedir=/usr/local/mysql/ –datadir=/usr/local/mysql/data3307 –user=mysql
/usr/local/mysql//scripts/mysql_install_db –basedir=/usr/local/mysql/ –datadir=/usr/local/mysql/data3308 –user=mysql
4,啟動指令碼修改
cp /etc/init.d/mysql.server /etc/ini.d/mysql3307.server cp /etc/init.d/mysql.server /etc/init.d/mysql3308.server
然後修改裡面的配置路徑
5,分別啟動資料庫,啟動之前相關目錄許可權修改為mysql:mysql
/etc/init.d/mysql.server start /etc/init.d/mysql3307.server start /etc/init.d/mysql3308.server start
mysql多伺服器 mysql 多伺服器例項
測試環境是在windows下。不同系統啟動和停止命令有所差異 1 修改配置檔案 把需要配置的選項都設定成不一樣的 需要修改的地方有 client password your password port 3308 經過測試,這個埠改不改都沒什麼問題,但是還是改了保險點吧 socket d servic...
mysql多伺服器 單伺服器多mysql伺服器
mkdir home mysql servers mysql330 p useradd g mysql mysql3307 s bin nologin d home mysql servers mysql3307 tar xf mysql.tar.gz cd mysql configure pref...
單伺服器多MySQL安裝
client port 3457 設定mysql客戶端預設字符集 default character set utf8 mysqld 設定3306埠 port 3457 設定mysql的安裝目錄 basedir d mysql 5.7.26 winx642 設定mysql資料庫的資料的存放目錄 da...