The standalone server has the binary mysql5.6.20 installed, and then the MySQL multi-instance is turned on
Useradd mysql-s/sbin/nologin-m
Mkdir/data/{3307,3308}/{data,log,binlog}-P
cd/data/3307
Chown-r mysql.mysql./{binlog,data,log}
cd/usr/local/mysql/scripts/
Note: when initializing MySQL, be sure to remove the first/etc/my.cnf file or modify the name, and then initialize the multi-instance MySQL.
./mysql_install_db--datadir=/data/3307/data--basedir=/usr/local/mysql--user=mysql--explicit_defaults_for_ Timestamp
/usr/local/mysql/bin/mysqld_safe--DEFAULTS-FILE=/DATA/3307/MY.CNF &
Ps-ef|grep MySQL
mysqladmin-uroot password ' [email protected] '-s/data/3307/log/mysql.sock
MySQL configuration file:
[Email protected] log]# CAT/DATA/3307/MY.CNF
[Client]
#password = Your_password
Port = 3307
Socket =/data/3307/log/mysql.sock
[Mysqld]
Port = 3307
Socket =/data/3307/log/mysql.sock
DataDir =/data/3307/data/
Long_query_time = 1
Slow_query_log=1
Slow-query-log-file =/data/3307/log/mysql-slow.log
Log-error =/data/3307/log/error.log
Pid-file =/data/3307/log/mysql3307.pid
Character_set_server = UTF8
Skip-external-locking
Key_buffer_size = 16M
Max_allowed_packet = 1M
Table_open_cache = 1024
Sort_buffer_size = 4M
Net_buffer_length = 8K
Read_buffer_size = 4M
Read_rnd_buffer_size = 512K
Myisam_sort_buffer_size = 64M
Thread_cache_size = 128
Query_cache_size = 0
Tmp_table_size = 128M
Secure_file_priv =/tmp
Explicit_defaults_for_timestamp = True
#skip-networking
Max_connections = 500
max_connect_errors = 100
Open_files_limit = 65535
log-bin=/data/3307/binlog/mysql-bin
Binlog_format=row
Server-id = 37307
Expire_logs_days = 2
Log_bin_trust_function_creators=1
Default_storage_engine = InnoDB
Innodb_data_home_dir =/data/3307/data
Innodb_data_file_path = Ibdata1:10m:autoextend
Innodb_log_group_home_dir =/data/3307/data
Innodb_buffer_pool_size = 3072M
Innodb_log_file_size = 256M
Innodb_log_buffer_size = 8M
Innodb_flush_log_at_trx_commit = 1
Innodb_lock_wait_timeout = 50
[Mysqldump]
Quick
Max_allowed_packet = 256M
[MySQL]
#prompt = ' \\[email protected]\\h: \\d:\\d> '
No-auto-rehash
#prompt = "\\[email protected]\\h [\\d]>"
[Myisamchk]
Key_buffer_size = 16M
Sort_buffer_size = 4M
Read_buffer = 2M
Write_buffer = 2M
[Mysqlhotcopy]
Interactive-timeout
Turn on MySQL instance 3308
cd/data/3308
Chown-r mysql.mysql./{binlog,data,log}
./mysql_install_db--datadir=/data/3307/data--basedir=/usr/local/mysql--user=mysql--explicit_defaults_for_ Timestamp
/usr/local/mysql5.6/bin/mysqld_safe--DEFAULTS-FILE=/DATA/3307/MY.CNF &
mysqladmin-uroot password ' [email protected] '-s/data/3307/log/mysql.sock
Single-machine multi-instance MySQL startup script:
[Email protected] log]# cat/data/3307/mysql.sh
#!/bin/sh
################################################
################################################
#init
port=3307
Mysql_user= "Root"
mysql_pwd= "[Email protected]"
Cmdpath= "/usr/local/mysql/bin"
mysql_sock= "/data/$port/log/mysql.sock"
#startup function
Function_start_mysql ()
{
if [!-e "$mysql _sock"];then
printf "Starting mysql...\n"
${cmdpath}/mysqld_safe--defaults-file=/data/${port}/my.cnf 2>&1 >/dev/null &
Else
printf "MySQL is running...\n"
Exit
Fi
}
#stop function
Function_stop_mysql ()
{
if [!-e "$mysql _sock"];then
printf "MySQL is stopped...\n"
Exit
Else
printf "stoping mysql...\n"
${cmdpath}/mysqladmin-u ${mysql_user}-p${mysql_pwd}-s/data/${port}/log/mysql.sock shutdown & >/dev/null
Fi
}
#restart function
Function_restart_mysql ()
{
if [!-e "$mysql _sock"];then
printf "MySQL is stopped...\n"
Else
printf "stoping mysql...\n"
${cmdpath}/mysqladmin-u ${mysql_user}-p${mysql_pwd}-s/data/${port}/log/mysql.sock shutdown & >/dev/null
Fi
Sleep 1
Function_start_mysql
}
Case $ in
Start
Function_start_mysql
;;
Stop
Function_stop_mysql
;;
Restart
Function_restart_mysql
;;
*)
printf "Usage:/data/${port}/mysql.sh {start|stop|restart}\n"
Esac
This article is from the "10931853" blog, please be sure to keep this source http://wujianwei.blog.51cto.com/10931853/1969116
The standalone server has the binary mysql5.6.20 installed, and then the MySQL multi-instance is turned on