2012년 9월 10일 월요일

mysql multiport

[설치 위치]
/usr/local/mysql

/etc/my.cnf
[mysqld]
user       = mysql
basedir    = /usr/local/mysql
log-error  = /var/log/mysqld.err
socket     = /var/run/mysqld/mysql.sock
pid-file   = /var/run/mysqld/mysql.pid


[mysqld_multi]
mysqld     = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin


[mysqld1]
socket     = /var/run/mysqld/mysql1.sock
port       = 3306
pid-file   = /var/run/mysqld/mysql1.pid
datadir    = /home/mysql
ledir      = /usr/local/mysql/bin


[mysqld2]
socket     = /var/run/mysqld/mysql2.sock
port       = 3307
pid-file   = /var/run/mysqld/mysql2.pid
datadir    = /home/mysql2
ledir      = /usr/local/mysql/bin


[mysqld3]
socket     = /var/run/mysqld/mysql3.sock
port       = 3308
pid-file   = /var/run/mysqld/mysql3.pid
datadir    = /home/mysql3
ledir      = /usr/local/mysql/bin


[데이터 디렉토리 생성]
# mkdir /home/mysql; mkdir /home/mysql2; mkdir /home/mysql3;
# chown -R mysql:mysql /home/mysql
# chown -R mysql:mysql /home/mysql2
# chown -R mysql:mysql /home/mysql3


[socket, pid 디렉토리 생성]
# mkdir /var/run/mysqld; chown -R mysql:mysql /var/run/mysqld


[데이터 DB 파일 생성]
# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/home/mysql
# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/home/mysql2
# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/home/mysql3


[데몬 실행]
mysqld1 ~ 3 모두 기동
# /usr/local/mysql/bin/mysqld_multi start

특정 포트만 기동|종료
# /usr/local/mysql/bin/mysqld_multi 번호 start|stop


[서버 접속]
# /usr/local/mysql/bin/mysql -u root -h 127.0.0.1 -P 3306
# /usr/local/mysql/bin/mysql -u root -h 127.0.0.1 -P 3307
# /usr/local/mysql/bin/mysql -u root -h 127.0.0.1 -P 3308

댓글 없음:

댓글 쓰기