網(wǎng)上找了N多資料,沒有一個(gè)可以順利成功的,郁悶,可能是水平有限吧...!本人經(jīng)過不斷的研究、測(cè)試,完整實(shí)現(xiàn)linux下啟動(dòng)兩臺(tái)MySQL,而且對(duì)mysql有了更深入的了解...廢話不多說,走著!
創(chuàng)新互聯(lián)主要從事網(wǎng)站設(shè)計(jì)制作、做網(wǎng)站、網(wǎng)頁(yè)設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)名山,十多年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來(lái)電咨詢建站服務(wù):18980820575
步驟如下:
一、編譯安裝兩個(gè)mysql,步驟如下
下載Mysql ,此處以Mysql-6.0.11-alpha.tar.gz為例
安裝第一個(gè)數(shù)據(jù)庫(kù)(主數(shù)據(jù)庫(kù))
(紅色部分為默認(rèn)數(shù)據(jù)庫(kù)文件路徑,可改成其他如:data、var等)
tar zxvf mysql-6.0.11-alpha.tar.gz
cdmysql-6.0.11-alpha
./configure--prefix=/usr/local/mysql --sysconfdir=/usr/local/mysql/etc--with-tcp-port=3306 --localstatedir=/usr/local/mysql/localstate--with-unix-socket-path=/tmp/mysql3306.sock --with-charset=utf8 --with-collation=utf8_general_ci--with-extra-charsets=gbk,gb2312,binary --enable-thread-safe-client--with-plugins=innobase --with-mysqld-user=mysql --with-charset=utf8 --with-client-ldflags=-all-static--with-mysqld-ldflags=-all-static
make &&make install
安裝第二個(gè)數(shù)據(jù)庫(kù)(從數(shù)據(jù)庫(kù))
tar zxvfmysql-6.0.11-alpha.tar.gz
cdmysql-6.0.11-alpha
./configure--prefix=/usr/local/mysql3307 --sysconfdir=/usr/local/mysql3307/etc--with-tcp-port=3307 --localstatedir=/usr/local/mysql3307/localstate --with-unix-socket-path=/tmp/mysql3307.sock--with-charset=utf8 --with-collation=utf8_general_ci--with-extra-charsets=gbk,gb2312,binary --enable-thread-safe-client--with-plugins=innobase --with-mysqld-user=mysql --with-charset=utf8 --with-client-ldflags=-all-static--with-mysqld-ldflags=-all-static
make &&make install
如需支持所有字符集 修改為:--with-extra-charsets=all 即可
二、分別初始化數(shù)據(jù)庫(kù)腳本(在編譯目錄執(zhí)行下)
scripts/mysql_install_db--basedir=/usr/local/mysql/ --user=mysql
scripts/mysql_install_db--basedir=/usr/local/mysql3307/ --user=mysql
注:可用--datadir=PATH參數(shù)指定數(shù)據(jù)庫(kù)文件路徑,默認(rèn)為編譯時(shí)-- localstatedir
三、修改從庫(kù)配置文件
拷貝配置文件:
cp/usr/local/software/mysql-6.0.11-alpha/support-files/my-medium.cnf/usr/local/mysql/etc/my.cnf
cp/usr/local/software/mysql-6.0.11-alpha/support-files/my-medium.cnf/usr/local/mysql3307/etc/my.cnf
四、修改各個(gè)數(shù)據(jù)庫(kù)的my.cnf文件
主要內(nèi)容如下:
添加InnoDB支持:
[client]
#password =your_password
port = 3307 --數(shù)據(jù)庫(kù)端口號(hào)
socket = /tmp/mysqls.sock--sock文件路徑
default-character-set=utf8 --客戶端UTF8連接
[mysqld]
port = 3307 --數(shù)據(jù)庫(kù)端口號(hào)
socket = /tmp/mysqls.sock --sock文件路徑
default-storage-engine=INNODB
default-character-set=UTF8 --默認(rèn)字符集
init_connect='SETNAMES utf8' --以UTF8連接
skip-name-resolve --取消DNS反向解析
lower_case_table_names=1 --不區(qū)分表名大小寫
啟動(dòng)數(shù)據(jù)庫(kù)(進(jìn)入各自目錄)
主:./mysqld_safe&
從:./mysqld_safe&
配置開啟自動(dòng):
cp/usr/local/software/mysql-6.0.11-alpha/support-files/mysql.server/etc/init.d/mysql
cp/usr/local/software/mysql-6.0.11-alpha/support-files/mysql.server/etc/init.d/mysql3307
修改/etc/init.d/mysql3007中basedir與datadir為即可
basedir=/usr/local/mysql3307
datadir=/usr/local/mysql3307/var
停止數(shù)據(jù)庫(kù)
主:./mysqladminshutdown
從:./mysqladminshutdown
以上各項(xiàng)配置都可以自行修改,以滿足業(yè)務(wù)需求。