[Email protected] ~]# ll/usr/local/|grep mysqllrwxrwxrwx. 1 root root June 01:52 MySQL--/alidata/server/mysql# This is a script-free installation environment (more complex)
[Email protected]/]# tree/data//data/├──3307│└──data└──3308 └──data4 directories, 0 files
[[email protected] 3307]# find/data-type f-name mysql |xargs chmod 700
[Email protected] scripts]# lsmysql_install_db[[email protected] scripts]# pwd/alidata/server/mysql/scripts
[Email protected] scripts]#/mysql_install_db--basedir=/alidata/server/mysql--datadir=/data/3307/data--user= Mysql[[email protected] scripts]#./mysql_install_db--basedir=/alidata/server/mysql--datadir=/data/3308/data-- User=mysql
/usr/local/mysql/bin/mysqld:file '/data/3307/mysql-bin.index ' not Found (errcode:13) 160614 5:46:15 [ERROR] aborting# no permissions [email protected] data]# chown-r mysql:mysql 330*[[email protected] data]# lltotal 8drwxr-xr-x. 3 MySQL mysql 4096 June 06:03 3307drwxr-xr-x. 3 MySQL mysql 4096 June 14 05:48 3308
[Email protected] 3308]#/mysql start+ port=3308+ echo 33083308+ mysql_user=root+ cmdpath=/usr/local/mysql/bin+ Mysql_ sock=/data/3308/mysql.sock+ Case $ in+ function_start_mysql+ ' ['! '-e/data/3308/mysql.sock '] ' + printf ' starting MySQL ... \ n ' Starting mysql.....+/bin/bash/usr/local/mysql/bin/mysqld_safe--defaults-file=/data/3308/my.cnf
[Email protected] 3308]# netstat-lnutp|grep mysqldtcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 16239/ mysqld TCP 0 0 0.0.0.0:3307 0.0.0.0:* LISTEN 24077/mysqld tcp 0 0 0.0.0.0:3308 0.0.0.0:* LISTEN
[Email protected] 3308]# mysql-uroot-p-s/data/3308/mysql.sock Enter password:welcome to the MySQL monitor.
Close the database for different ports: [[email protected] 3307]#./mysql stop3307stoping mysql ..... [Email protected] 3307]# netstat-lnutp|grep mysqldtcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 16239/ Mysqld
--------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------
[Email protected] ~]# ls/data/330*/data/3307:data my.cnf mysql mysql_barry3307.err mysql-bin.000001 mysql-bin.index mysqld.pid mysql.sock slow.log/data/3308:data my.cnf MySQL mysql_barry3308.err mysql-bin.000001 mysql-bin.index mysqld.pid mysql.sock slow.log# below There are scripts for MySQL content and my.cnf content
[[email protected] ~]# cat/data/3307/my.cnf[client]port = 3307[mysql]no-auto-rehash[mysqld]user = mysq Lport = 3307basedir =/usr/local/mysqldatadir =/data/3307/datasocket =/data/3307/mysql.sockopen_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 = 2Mque Ry_cache_limit = 1mquery_cache_min_res_unit = 2k#default_table_type = Innodbthread_stack = 192Ktransaction_isolation = Read-committedtmp_table_size = 2mmax_heap_table_size = 2mlong_query_time = 1#log_long_formatlog-error =/data/3307/ Error.loglog-slow-queries =/data/3307/slow.logpid-file =/data/3307/mysql.pidlog-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 = 1Mmyisam_sort_buffer_size = 1mmyisam_max_sort_file_size = 10g#myisam_max_extra_sort_file_size = 10gmyisam_repair_threads = 1myisam_recoverlower_ Case_table_names = 1skip-name-resolveslave-skip-errors = 1032,1062replicate-ignore-db=mysqlserver-id = 2innodb_ 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_barry3307.errpid-file= /data/3307/mysqld.pid
[[email protected] ~]# cat/data/3307/mysql#!/bin/bash#mysql Multi-instance startup script #initport=3307echo $portmysql _user= "Root" # Mysql_pwd= "" #注意密码CmdPath = "/usr/local/mysql/bin" mysql_sock= "/data/${port}/mysql.sock" #startup functionfunction_ Start_mysql () {if [!-e "$mysql _sock"];thenprintf "Starting mysql.....\n"/bin/bash ${cmdpath}/mysqld_safe-- DEFAULTS-FILE=/DATA/${PORT}/MY.CNF 2>&1 >/dev/null&else printf "MySQL is running......\n" Exitfi} #stop F Unctionfunction_stop_mysql () {if [!-e "$mysql _sock"];thenprintf "MySQL is stopped ... \ n" exitelseprintf "stoping MySQL. ... \ n "${cmdpath}/mysqladmin-u ${mysql_user}-s/data/${port}/mysql.sock shutdownfi #如查有密码加-p${mysql_pwd}} #restart Functionfunction_restart_mysql () {printf "restarting mysql......\n" Function_stop_mysqlsleep 2function_start_mysql} Case $ in "start") function_start_mysql;; " Stop ") function_stop_mysql;;" Restart ") Function_restart_mysql;; *) printf "Usage:/data/${port}/mysql {start|stop|restart}\n" Esac
Port 3308 Ibid, change 3307 to 3308!
Baidu Network Disk (well-equipped configuration file): Http://pan.baidu.com/s/1bo6MTGV
MySQL multi-instance (personal situation, not public) there are well-configured scripts