日期:2014-05-16  浏览次数:20939 次

一台服务器上配置多台Mysql实例
一台服务器上配置多台Mysql实例
2011-07-25 14:20

1  先配置一个mysql数据库  并创一个可以关闭数据库的账号grant shutdown on *.* to multi_admin@'localhost' identified by '123456';  装完第一个就创建  在第三步时 账号也就cp 过去了。   安装第一个数据库参照以前写过的文档
2 stop mysql  
3  cp 第一个数据库的目录  到第二个数据库  第三个数据库  第四个数据库    例如:第一个数据库文件放到/usr/loca/mysq/var   cp -P var var1     第三个和第四个一样

4  写配置文件  如下 /etc/my.cnf
[mysql]

character-sets-dir=/usr/local/mysql/share/mysql/charsets
default-character-set=utf8
disable-auto-rehash

[mysqladmin]
character-sets-dir=/usr/local/mysql/share/mysql/charsets
default-character-set=utf8

[mysqlcheck]
character-sets-dir=/usr/local/mysql/share/mysql/charsets
default-character-set=utf8

[mysqldump]
character-sets-dir=/usr/local/mysql/share/mysql/charsets
default-character-set=utf8

[mysqlimport]
character-sets-dir=/usr/local/mysql/share/mysql/charsets
default-character-set=utf8

[mysqlshow]
character-sets-dir=/usr/local/mysql/share/mysql/charsets
default-character-set=utf8

[myisamchk]
character-sets-dir=/usr/local/mysql/share/mysql/charsets

[myisampack]
character-sets-dir=/usr/local/mysql/share/mysql/charsets

# use [safe_mysqld] with mysql-3
[mysqld_safe]
err-log     = /var/log/mysql/mysql.err


[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
user = multi_admin
password = 123456
[mysqld0]
character-set-server            = utf8
default-character-set           = utf8
port      = 3306
socket    = /var/run/mysql/s0
#socket = /var/run/mysql/mysql1.sock
pid-file = /var/run/mysql/db-app1.pid
log-error = /var/log/mysql/mysql1err.log
#log = /var/log/mysql/db1-app.log
datadir = /usr/local/mysql/var
max_allowed_packet                      = 1M
table_cache                             = 64
sort_buffer_size                        = 512K
net_buffer_length                       = 8K
read_buffer_size                        = 256K
read_rnd_buffer_size            = 512K
myisam_sort_buffer_size         = 8M
language                                        = /usr/local/mysql/share/mysql/english
max_user_connections     = 5
max_connections         = 300
open_files_limit = 16384
skip-show-database
user = mysql
#skip-innodb
tmpdir                                       &