tar zxf mysql-5.5.32.tar.gz cd mysql-5.5.32[root@mysql mysql-5.5.32]# rm CMakeCache.txt ###删除这个文件,重新cmake [root@mysql /]# unzip data.zip ##上传到根下,加压会替换上面创建的/data目录Archive: data.zip inflating: data/3306/my.cnf inflating: data/3306/mysql inflating: data/3307/my.cnf inflating: data/3307/mysql [root@mysql /]# tree /datadata/ data.zip [root@mysql /]# tree datadata/ data.zip [root@mysql /]# tree data/data/├──3306│??├── data│??├── my.cnf ##实例的配置文件│??└── mysql ##实例的启动文件├──3307│??├── data │??├── my.cnf ##实例的配置文件│??└── mysql ##实例的启动文件└── test[root@mysql /]# cat /data/3306/my.cnf [client]port =3306socket =/data/3306/mysql.sock[mysql]no-auto-rehash[mysqld]user = mysqlport =3306socket =/data/3306/mysql.sockbasedir =/application/mysqldatadir =/data/3306/dataopen_files_limit =1024back_log =600max_connections =800max_connect_errors =3000table_cache =614external-locking = FALSEmax_allowed_packet =8Msort_buffer_size =1Mjoin_buffer_size =1Mthread_cache_size =100thread_concurrency =2query_cache_size =2Mquery_cache_limit =1Mquery_cache_min_res_unit =2k#default_table_type = InnoDBthread_stack =192K#transaction_isolation = READ-COMMITTEDtmp_table_size =2Mmax_heap_table_size =2Mlong_query_time =1#log_long_format#log-error = /data/3306/error.log#log-slow-queries = /data/3306/slow.logpid-file =/data/3306/mysql.pidlog-bin =/data/3306/mysql-binrelay-log =/data/3306/relay-binrelay-log-info-file =/data/3306/relay-log.infobinlog_cache_size =1Mmax_binlog_cache_size =1Mmax_binlog_size =2Mexpire_logs_days =7key_buffer_size =16Mread_buffer_size =1Mread_rnd_buffer_size =1Mbulk_insert_buffer_size =1M#myisam_sort_buffer_size = 1M#myisam_max_sort_file_size = 10G#myisam_max_extra_sort_file_size = 10G#myisam_repair_threads = 1#myisam_recoverlower_case_table_names =1skip-name-resolveslave-skip-errors =1032,1062replicate-ignore-db=mysqlserver-id =1innodb_additional_mem_pool_size =4Minnodb_buffer_pool_size =32Minnodb_data_file_path = ibdata1:128M:autoextendinnodb_file_io_threads =4innodb_thread_concurrency =8innodb_flush_log_at_trx_commit =2innodb_log_buffer_size =2Minnodb_log_file_size =4Minnodb_log_files_in_group =3innodb_max_dirty_pages_pct =90innodb_lock_wait_timeout =120innodb_file_per_table =0[mysqldump]quickmax_allowed_packet =2M[mysqld_safe]log-error=/data/3306/mysql_oldboy3306.errpid-file=/data/3306/mysqld.pid[root@mysql /]# cat /data/3307/my.cnf [client]port =3307socket =/data/3307/mysql.sock[mysql]no-auto-rehash[mysqld]user = mysqlport =3307socket =/data/3307/mysql.sockbasedir =/application/mysqldatadir =/data/3307/dataopen_files_limit =1024back_log =600max_connections =800max_connect_errors =3000table_cache =614external-locking = FALSEmax_allowed_packet =8Msort_buffer_size =1Mjoin_buffer_size =1Mthread_cache_size =100thread_concurrency =2query_cache_size =2Mquery_cache_limit =1Mquery_cache_min_res_unit =2k#default_table_type = InnoDBthread_stack =192K#transaction_isolation = READ-COMMITTEDtmp_table_size =2Mmax_heap_table_size =2M#long_query_time = 1#log_long_format#log-error = /data/3307/error.log#log-slow-queries = /data/3307/slow.logpid-file =/data/3307/mysql.pid#log-bin = /data/3307/mysql-binrelay-log =/data/3307/relay-binrelay-log-info-file =/data/3307/relay-log.infobinlog_cache_size =1Mmax_binlog_cache_size =1Mmax_binlog_size =2Mexpire_logs_days =7key_buffer_size =16Mread_buffer_size =1Mread_rnd_buffer_size =1Mbulk_insert_buffer_size =1M#myisam_sort_buffer_size = 1M#myisam_max_sort_file_size = 10G#myisam_max_extra_sort_file_size = 10G#myisam_repair_threads = 1#myisam_recoverlower_case_table_names =1skip-name-resolveslave-skip-errors =1032,1062replicate-ignore-db=mysqlserver-id =3innodb_additional_mem_pool_size =4Minnodb_buffer_pool_size =32Minnodb_data_file_path = ibdata1:128M:autoextendinnodb_file_io_threads =4innodb_thread_concurrency =8innodb_flush_log_at_trx_commit =2innodb_log_buffer_size =2Minnodb_log_file_size =4Minnodb_log_files_in_group =3innodb_max_dirty_pages_pct =90innodb_lock_wait_timeout =120innodb_file_per_table =0[mysqldump]quickmax_allowed_packet =2M[mysqld_safe]log-error=/data/3307/mysql_oldboy3307.errpid-file=/data/3307/mysqld.pid特别说明: mysqladmin -u root -p123456 -S /data/3306/mysql.sock shutdown 如果不为MySQL的命令配置全局路径,就无法直接在命令行输入mysql,这样只能用全路径/application/msyq/bin/mysql 这样带着路径输出会比较麻烦[root@mysql /]# tail -1/etc/profileexport PATH=/application/mysql/bin:$PATH ##添加如下行[root@mysql /]# source /etc/profile ##让其生效[root@mysql /]# echo $PATH/application/mysql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bincd /application/mysql/scripts/##注意和MySQL 5.1的路径不同,MySQL 5.1 不在mysql/bin下./mysql_install_db --basedir=/application/mysql --datadir=/data/3306/data/--user=mysql./mysql_install_db --basedir=/application/mysql --datadir=/data/3307/data/--user=mysql当初始化的过程中出现两个OK时,表示初始化成功[root@mysql scripts]# sed -i '13 s#oldboy#123456#g'/data/3306/mysql[root@mysql scripts]# sed -n '13p'/data/3306/mysqlmysql_pwd="123456"[root@mysql scripts]# sed -i '13 s#oldboy#123456#g' /data/3307/mysql[root@mysql scripts]# sed -n '13p' /data/3307/mysql mysql_pwd="123456"[root@mysql scripts]# [root@mysql scripts]#/data/3306/mysql stopStopingMySQL...[root@mysql scripts]#/data/3307/mysql stop StopingMySQL...[root@mysql scripts]#新增一个多实例库3308,操作命令如下 附件列表 原标题:MySQL多实例安装 关键词:MYSQL
[root@mysql mysql-5.5.32]# rm CMakeCache.txt ###删除这个文件,重新cmake
[root@mysql /]# unzip data.zip ##上传到根下,加压会替换上面创建的/data目录
Archive: data.zip
inflating: data/3306/my.cnf
inflating: data/3306/mysql
inflating: data/3307/my.cnf
inflating: data/3307/mysql
[root@mysql /]# tree /data
data/ data.zip
[root@mysql /]# tree data
[root@mysql /]# tree data/
data/
├──3306
│??├── data
│??├── my.cnf ##实例的配置文件
│??└── mysql ##实例的启动文件
├──3307
└── test
[root@mysql /]# cat /data/3306/my.cnf
[client]
port =3306
socket =/data/3306/mysql.sock
[mysql]
no-auto-rehash
[mysqld]
user = mysql
basedir =/application/mysql
datadir =/data/3306/data
open_files_limit =1024
back_log =600
max_connections =800
max_connect_errors =3000
table_cache =614
external-locking = FALSE
max_allowed_packet =8M
sort_buffer_size =1M
join_buffer_size =1M
thread_cache_size =100
thread_concurrency =2
query_cache_size =2M
query_cache_limit =1M
query_cache_min_res_unit =2k
#default_table_type = InnoDB
thread_stack =192K
#transaction_isolation = READ-COMMITTED
tmp_table_size =2M
max_heap_table_size =2M
long_query_time =1
#log_long_format
#log-error = /data/3306/error.log
#log-slow-queries = /data/3306/slow.log
pid-file =/data/3306/mysql.pid
log-bin =/data/3306/mysql-bin
relay-log =/data/3306/relay-bin
relay-log-info-file =/data/3306/relay-log.info
binlog_cache_size =1M
max_binlog_cache_size =1M
max_binlog_size =2M
expire_logs_days =7
key_buffer_size =16M
read_buffer_size =1M
read_rnd_buffer_size =1M
bulk_insert_buffer_size =1M
#myisam_sort_buffer_size = 1M
#myisam_max_sort_file_size = 10G
#myisam_max_extra_sort_file_size = 10G
#myisam_repair_threads = 1
#myisam_recover
lower_case_table_names =1
skip-name-resolve
slave-skip-errors =1032,1062
replicate-ignore-db=mysql
server-id =1
innodb_additional_mem_pool_size =4M
innodb_buffer_pool_size =32M
innodb_data_file_path = ibdata1:128M:autoextend
innodb_file_io_threads =4
innodb_thread_concurrency =8
innodb_flush_log_at_trx_commit =2
innodb_log_buffer_size =2M
innodb_log_file_size =4M
innodb_log_files_in_group =3
innodb_max_dirty_pages_pct =90
innodb_lock_wait_timeout =120
innodb_file_per_table =0
[mysqldump]
quick
max_allowed_packet =2M
[mysqld_safe]
log-error=/data/3306/mysql_oldboy3306.err
pid-file=/data/3306/mysqld.pid
[root@mysql /]# cat /data/3307/my.cnf
port =3307
socket =/data/3307/mysql.sock
datadir =/data/3307/data
#long_query_time = 1
#log-error = /data/3307/error.log
#log-slow-queries = /data/3307/slow.log
pid-file =/data/3307/mysql.pid
#log-bin = /data/3307/mysql-bin
relay-log =/data/3307/relay-bin
relay-log-info-file =/data/3307/relay-log.info
server-id =3
log-error=/data/3307/mysql_oldboy3307.err
pid-file=/data/3307/mysqld.pid
[root@mysql /]# tail -1/etc/profile
export PATH=/application/mysql/bin:$PATH ##添加如下行
[root@mysql /]# source /etc/profile ##让其生效
[root@mysql /]# echo $PATH
/application/mysql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
cd /application/mysql/scripts/##注意和MySQL 5.1的路径不同,MySQL 5.1 不在mysql/bin下
./mysql_install_db --basedir=/application/mysql --datadir=/data/3306/data/--user=mysql
./mysql_install_db --basedir=/application/mysql --datadir=/data/3307/data/--user=mysql
[root@mysql scripts]# sed -i '13 s#oldboy#123456#g'/data/3306/mysql
[root@mysql scripts]# sed -n '13p'/data/3306/mysql
mysql_pwd="123456"
[root@mysql scripts]# sed -i '13 s#oldboy#123456#g' /data/3307/mysql[root@mysql scripts]# sed -n '13p' /data/3307/mysql mysql_pwd="123456"[root@mysql scripts]# [root@mysql scripts]#/data/3306/mysql stopStopingMySQL...[root@mysql scripts]#/data/3307/mysql stop StopingMySQL...[root@mysql scripts]#新增一个多实例库3308,操作命令如下 附件列表 原标题:MySQL多实例安装 关键词:MYSQL
[root@mysql scripts]#/data/3306/mysql stop
StopingMySQL...
[root@mysql scripts]#/data/3307/mysql stop
[root@mysql scripts]#
原标题:MySQL多实例安装
关键词:MYSQL