mysql 多實例

一.安裝mysql

mysql

 

二.配置my.cnf

[mysqld3306]
port=3306
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql3306.sock
pid-file=/var/run/mysqld/mysqld3306.pid
log-error = /var/lib/mysql/error.log

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[mysqld3307]
port=3307
datadir=/var/lib/mysql3307
socket=/var/lib/mysql3307/mysql3307.sock
pid-file=/var/run/mysqld/mysqld3307.pid
log-error = /var/lib/mysql3307/error.log

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES


[mysqld3308]
port=3308
datadir=/var/lib/mysql3308
socket=/var/lib/mysql3308/mysql3308.sock
pid-file=/var/run/mysqld/mysqld3308.pid
log-error = /var/lib/mysql3308/error.log

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES


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

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

  

三.建立和初始化數據目錄

1.在/var/lib下建立mysql3307和mysql3308sql

2.賦予權限socket

chown mysql:mysql /var/lib/mysql3307
.....

  

3.初始化:blog

...
mysql_install_db --basedir=/usr/local/mysql/ --datadir=/var/lib/mysql3307 --defaults-file=/etc/my.cnf
...

  

四.多實例管理

啓動所有實例:/usr/local/mysql/bin/mysqld_multi start
查看所有實例狀態:/usr/local/mysql/bin/mysqld_multi report
啓動單個實例:/usr/local/mysql/bin/mysqld_multi start 3306
中止單個實例:/usr/local/mysql/bin/mysqld_multi stop 3306
查看單個實例狀態:/usr/local/mysql/bin/mysqld_multi report 3306it

相關文章
相關標籤/搜索