數(shù)據(jù)庫的安裝路徑:/usr/local/mysql
數(shù)據(jù)目錄:/data/mysql/data
(此處mysql的解壓就不再列出來了)
在原來的環(huán)境上已經(jīng)有安裝了一個實例port3306
在此處要新進2個實例(端口為3307,3308)
[root@master2 mysql]# pwd
/data/mysql
# mkdir data3307
# mkdir data3308
chown -R mysql:mysql .
# cd scripts/
# ls
mysql_install_db
./mysql_install_db --user=mysql datadir=/data/mysql/data3307
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/data3307/
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/data3308/
配置文件(/etc/my.cnf)
[mysqld_multi]
mysqld=/usr/local/mysql/bin/mysqld
mysqladmin=/usr/local/mysql/bin/mysqladmin
user=admin
password=123456
[mysqld3306]
port=3306
pid-file=/data/mysql/data/master2.pid
datadir=/data/mysql/data
basedir=/usr/local/mysql
socket=/tmp/mysql.sock
user = mysql
server-id = 3306
[mysqld3307]
socket=/tmp/mysql3307.sock
port=3307
datadir=/data/mysql/data3307
pid-file=/data/mysql/data/mysql3307.pid
basedir=/usr/local/mysql
user = mysql
server-id = 3307
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld3308]
socket=/tmp/mysql3308.sock
port=3308
datadir=/data/mysql/data3308
pid-file=/data/mysql/data/mysql3308.pid
basedir=/usr/local/mysql
user = mysql
server-id = 3308
啟動三個mysql服務(wù)
mysqld_multi start 3306
mysqld_multi start 3307
mysqld_multi start 3308
#mysql -uroot -p123456 -S ./mysql.sock(3306端口的已經(jīng)設(shè)置了密碼了)
mysql -uroot -p -S ./mysql3307.sock #登錄mysql
mysql -uroot -p -S ./mysql3308.sock
netstat -ntlp |grep mysql #查看mysql端口監(jiān)聽
[root@master2 lib]# netstat -ntlp |grep mysql
tcp 0 0 :::3307 :::* LISTEN 15878/mysqld
tcp 0 0 :::3308 :::* LISTEN 15968/mysqld
tcp 0 0 :::3306 :::* LISTEN 15819/mysqld
設(shè)置新密碼
mysqladmin -uroot -S /tmp/mysql_3307.sock password 123456
mysqladmin -uroot -S /tmp/mysql_3308.sock password 123456
設(shè)置權(quán)限(3307,3308,3306)都要設(shè)置
grant all on *.* to admin@'%' identified by 'root' with grant option;
查看日志
cd /usr/local/mysql/share
# tail -f mysqld_multi.log
文章標(biāo)題:day1(多實例配置)-創(chuàng)新互聯(lián)
本文URL:
http://weahome.cn/article/jjpop.html