=====================================客户端my_330X.cnf配置文件如下===================================== # The following options will be passed to all MySQL clients [client] socket = /data/mysql_330X/log/mysql.sck port = 3306 default-character-set = utf8
另外一个简单的单机多实例的办法(WINDOWS下) 1:下载免安装版本,分别拷贝2份到D:\MYSQL D:\MYSQL1 2:分别在mysql,mysql1里面用mysqld install mysql mysql install mysql1注册2个服务 3:分别net start mysql net start mysql1启动2个服务
=====================割个JJ====================================
基础提要:
skip-name-resolve选项开启时:
1.localhost用户使用的是socket连接。
2.ip+port用户使用的是tcp连接。
mysql客户端连接时,默认使用my.cnf配置文件的[client]段,若要使用其他名字的配置文件,需要--default-files=/path/to/my.cnf来指定。
安装流程:
1.正常编译并安装MySQL.
安装目录:/usr/local/mysql
2.创建多实例各自的数据目录、日志目录等,并初始化各个实例.
/usr/local/mysql/bin/mysql_install_db --datadir=/data/mysql_3301/data --user=mysql
/usr/local/mysql/bin/mysql_install_db --datadir=/data/mysql_3302/data --user=mysql
3.配置服务器端用my_multi.cnf.
配置文件为/etc/my_multi.cnf
具体内容见下面"服务器端my_multi.cnf配置文件"详细配置
4.配置客户端用my_330X.cnf.
创建下面两个cnf,只需要指定[client]这个section就可以了
/data/mysql_3301/data/my_3301.cnf
/data/mysql_3301/data/my_3302.cnf
具体内容见下面"客户端my_330X.cnf配置文件"详细配置
5.启动多实例.
/usr/local/mysql/bin/mysqld_multi --defaults-file=/etc/my_multi.cnf start 1
/usr/local/mysql/bin/mysqld_multi --defaults-file=/etc/my_multi.cnf start 2
6.登录多实例.
/usr/local/mysql/bin/mysql --defaults-file=/data/mysql_3301/data/my_3301.cnf -uroot -p
/usr/local/mysql/bin/mysql --defaults-file=/data/mysql_3302/data/my_3302.cnf -uroot -p
7.停止多实例.
/usr/local/mysql/bin/mysqld_multi --defaults-file=/etc/my_multi.cnf stop 1
/usr/local/mysql/bin/mysqld_multi --defaults-file=/etc/my_multi.cnf stop 2
=====================================服务器端my_multi.cnf配置文件如下=====================================
#############mysqld_multi configuration#############
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
log = /data/mysql_multi.log
##user&password是启动和关闭mysql实例的用户,不需要其它权限,有shutdown就可以,没有这个配置,将无法使用命令关闭实例
user = admin
password = admin123#############mysqld1instance configuration#############
[mysqld1]
## Common configuration
port = 3301
server-id = 3301
character_set_server = utf8
bind_address = 10.8.32.130
skip-name-resolve
skip-external-locking
tmpdir = /var/tmp
datadir = /data/mysql_3301/data
socket = /data/mysql_3301/log/mysql.sck
pid-file = /data/mysql_3301/log/mysql.pid
log-error = /data/mysql_3301/log/mysql.err
general_log_file = /data/mysql_3301/log/mysql.gnl
slow-query-log_file = /data/mysql_3301/log/mysql.slw
log_bin = /data/mysql_3301/log/mysql-bin
binlog_format = MIXED
general_log
slow_query_log
long_query_time = 1
max_connection = 128
thread_cache_size = 64
table_open_cache = 128
open_files_limit = 4096
max_allowed_packet = 1M
net_buffer_length = 512K
sort_buffer_size = 8M
join_buffer_size = 8M
read_buffer_size = 8M
read_rnd_buffer_size = 8M
tmp_table_size = 12M
max_heap_table_size = 12M
slow_launch_time = 10## MyISAM tables configuration
key_buffer_size = 16M
myisam_sort_buffer_size = 8M
concurrent_insert = 2## InnoDB tables configuration
innodb_file_per_table
innodb_buffer_pool_size = 2G
innodb_data_file_path = ibdata1:20M:autoextend
innodb_data_home_dir = /data/mysql_3301/data
innodb_log_group_home_dir = /data/mysql_3301/iblog
innodb_log_files_in_group = 3
innodb_additional_mem_pool_size = 8M
innodb_log_file_size = 256M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 50
innodb_open_files = 500
innodb_thread_concurrency = 4
innodb_stats_on_metadata = OFF#############mysqld2 instance configuration#############
[mysqld2]
## Common configuration
port = 3302
server-id = 3302
character_set_server = utf8
bind_address = 10.8.32.130
skip-name-resolve
skip-external-locking
tmpdir = /var/tmp
datadir = /data/mysql_3302/data
socket = /data/mysql_3302/log/mysql.sck
pid-file = /data/mysql_3302/log/mysql.pid
log-error = /data/mysql_3302/log/mysql.err
general_log_file = /data/mysql_3302/log/mysql.gnl
slow-query-log_file = /data/mysql_3302/log/mysql.slw
log_bin = /data/mysql_3302/log/mysql-bin
binlog_format = MIXED
general_log
slow_query_log
long_query_time = 1
max_connection = 128
thread_cache_size = 64
table_open_cache = 128
open_files_limit = 4096
max_allowed_packet = 1M
net_buffer_length = 512K
sort_buffer_size = 8M
join_buffer_size = 8M
read_buffer_size = 8M
read_rnd_buffer_size = 8M
tmp_table_size = 12M
max_heap_table_size = 12M
slow_launch_time = 10## MyISAM tables configuration
key_buffer_size = 16M
myisam_sort_buffer_size = 8M
concurrent_insert = 2## InnoDB tables configuration
innodb_file_per_table
innodb_buffer_pool_size = 2G
innodb_data_file_path = ibdata1:20M:autoextend
innodb_data_home_dir = /data/mysql_3302/data
innodb_log_group_home_dir = /data/mysql_3302/iblog
innodb_log_files_in_group = 3
innodb_additional_mem_pool_size = 8M
innodb_log_file_size = 256M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 50
innodb_open_files = 500
innodb_thread_concurrency = 4
innodb_stats_on_metadata = OFF#############other configuration#############
[mysqldump]
quick
max_allowed_packet = 16M[mysql]
no-auto-rehash
safe-updates
# The following options will be passed to all MySQL clients
[client]
socket = /data/mysql_330X/log/mysql.sck
port = 3306
default-character-set = utf8
1:下载免安装版本,分别拷贝2份到D:\MYSQL D:\MYSQL1
2:分别在mysql,mysql1里面用mysqld install mysql mysql install mysql1注册2个服务
3:分别net start mysql net start mysql1启动2个服务
lz慢慢配 没有白费的功夫