本文系統:rhel5.8?
ip : 192.168.100.150
數據庫版本:mysql-5.6.15
1、創建部署mysql服務賬號:
1 2 3 4 | [root@daf?~] #?useradd?-d?/opt/mysql?mysql [root@daf?~] #?echo?"mysql"?|passwd?--stdin?mysql Changing?password? for ?user?mysql. passwd :?all?authentication?tokens?updated?successfully. |
2、解壓無需免裝包:配置環境變量
1 2 3 4 5 6 7 8 9 10 | [mysql@daf?~]$? tar ?zxvf?mysql-5.6.15-linux-glibc2.5-x86_64. tar .gz [mysql@daf?~]$? mv ?mysql-5.6.15-linux-glibc2.5-x86_64?mysql-5.6.15 [mysql@daf?mysql-5.6.15]$?vim?~/.bash_profile MYSQL_HOME= /opt/mysql/mysql-5 .6.15 export ?MYSQL_HOME PATH=$MYSQL_HOME /bin :$PATH export ?PATH |
3、配置多實例數據庫配置文件
1 2 3 4 5 6 7 | [root@daf?~] #?mkdir?/Data_for_Mysql [root@daf?~] #?chown?mysql.mysql?-R?/Data_for_Mysql/ [root@daf?~] #?su?-?mysql [mysql@daf?~]$? mkdir ?-p? /Data_for_Mysql/3301/data ?/Data_for_Mysql/3301/logs [mysql@daf?~]$? touch ?/Data_for_Mysql/3301/my .cnf [mysql@daf?~]$? mkdir ?-p? /Data_for_Mysql/3302/data ?/Data_for_Mysql/3302/logs [mysql@daf?~]$? touch ?/Data_for_Mysql/3302/my .cnf |
目錄結構:?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | [mysql@daf?Data_for_Mysql]$? pwd /Data_for_Mysql [mysql@daf?Data_for_Mysql]$?tree . |--?3301 |???|--?data |???|--?logs |???`--?my.cnf `--?3302 ???? |--?data ???? |--?logs ???? `--?my.cnf 6?directories,?2?files [mysql@daf?Data_for_Mysql]$ |
配置my.cnf ######本配置文件只供參考
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | [mysql@daf?3301]$?vim? /Data_for_Mysql/3301/my .cnf [client] port?=?3301 socket?=? /Data_for_Mysql/3301/data/mysql .sock [mysqld] user=msql port=3301 bind-address=192.168.100.150 socket?=? /Data_for_Mysql/3301/data/mysql .sock.3301 pid- file ?=? /Data_for_Mysql/3301/data/mysql .pid basedir?=? /opt/mysql/mysql-5 .6.15 datadir?=? /Data_for_Mysql/3301/data server- id =1 log-bin=mysql-bin log-bin-index=?mysql-bin.index #?LOGGING log_error= /Data_for_Mysql/3301/logs/mysql-error .log slow_query_log_file=? /Data_for_Mysql/3301/logs/mysql-slow .log slow_query_log=1 character-sets- dir ?=? /opt/mysql/mysql-5 .6.15 /share/charsets back_log?=?2000 max_connections?=?1000 connect-timeout?=?60 wait-timeout?=?28800 net_buffer_length?=?16384 max_allowed_packet?=?64M thread_stack?=?192K thread_cache_size?=?20 thread_concurrency?=?128 query_cache_size?=?256M query_cache_limit?=?2M query_cache_min_res_unit?=?2 default- time -zone?=?system character- set -server?=?utf8 default-storage-engine?=?InnoDB tmp_table_size?=?512M max_heap_table_size?=?512M max_binlog_size?=?1G max_relay_log_size?=?1G [mysql] disable-auto-rehash default-character- set ?=?utf8 |
4、初始化數據庫
1 2 3 | [mysql@daf?scripts]$? pwd /opt/mysql/mysql-5 .6.15 /scripts [mysql@daf?scripts]$?. /mysql_install_db ?--defaults- file = /Data_for_Mysql/3301/my .cnf?--user=mysql?--basedir= /opt/mysql/mysql-5 .6.15?--datadir= /Data_for_Mysql/3301/data/ |
5、啟動3301實例數據庫? ###啟動數據庫必須在mysql目錄;
1 2 3 4 5 6 | [mysql@daf?mysql-5.6.15]$? pwd /opt/mysql/mysql-5 .6.15 [mysql@daf?mysql-5.6.15]$?mysqld_safe?--defaults- file = /Data_for_Mysql/3301/my .cnf?--user=mysql?--basedir= /opt/mysql/mysql-5 .6.15?--datadir= /Data_for_Mysql/3301/data/ ?& [mysql@daf?mysql-5.6.15]$? netstat ?-nat?| grep ?3301 tcp????????0??????0?192.168.100.150:3301????????0.0.0.0:*???????????????????LISTEN |
Ps:3302?實例操作和上面一樣,只需改動端口及相應目錄即可;
3302配置文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | [mysql@daf?3302]$? cat ?my.cnf [client] port?=?3302 socket?=? /Data_for_Mysql/3302/data/mysql .sock [mysqld] user=mysql port=3302 bind-address=192.168.100.150 socket?=? /Data_for_Mysql/3302/data/mysql .sock.3302 pid- file ?=? /Data_for_Mysql/3302/data/mysql .pid basedir?=? /opt/mysql/mysql-5 .6.15 datadir?=? /Data_for_Mysql/3302/data server- id =1 log-bin=mysql-bin log-bin-index=?mysql-bin.index #?LOGGING log_error= /Data_for_Mysql/3302/logs/mysql-error .log slow_query_log_file=? /Data_for_Mysql/3302/logs/mysql-slow .log slow_query_log=1 character-sets- dir ?=? /opt/mysql/mysql-5 .6.15 /share/charsets back_log?=?2000 max_connections?=?1000 connect-timeout?=?60 wait-timeout?=?28800 net_buffer_length?=?16384 max_allowed_packet?=?64M thread_stack?=?192K thread_cache_size?=?20 thread_concurrency?=?128 query_cache_size?=?256M query_cache_limit?=?2M query_cache_min_res_unit?=?2 default- time -zone?=?system character- set -server?=?utf8 default-storage-engine?=?InnoDB tmp_table_size?=?512M max_heap_table_size?=?512M max_binlog_size?=?1G max_relay_log_size?=?1G [mysql] disable-auto-rehash default-character- set ?=?utf8 |
3302?實例初始化;
1 2 3 | [mysql@daf?scripts]$? pwd /opt/mysql/mysql-5 .6.15 /scripts [mysql@daf?scripts]$?. /mysql_install_db ?--defaults- file = /Data_for_Mysql/3302/my .cnf?--user=mysql?--basedir= /opt/mysql/mysql-5 .6.15?--datadir= /Data_for_Mysql/3302/data/ |
3302?啟動該實例:
1 2 3 4 5 | [mysql@daf?mysql-5.6.15]$?mysqld_safe?--defaults- file = /Data_for_Mysql/3302/my .cnf?--user=mysql?--basedir= /opt/mysql/mysql-5 .6.15?--datadir= /Data_for_Mysql/3302/data/ ?& [mysql@daf?mysql-5.6.15]$? netstat ?-nat?| grep ?330 tcp????????0??????0?192.168.100.150:3301????????0.0.0.0:*???????????????????LISTEN tcp????????0??????0?192.168.100.150:3302????????0.0.0.0:*???????????????????LISTEN |
6、創建root密碼,要區別實例
1 | [mysql@daf?mysql-5.6.15]$?mysqladmin?-uroot?password? 'root123' ?-S? /Data_for_Mysql/3301/data/mysql .sock.3301 |
6.1、關閉mysql,區別實例
1 2 3 4 | [mysql@daf?mysql-5.6.15]$?mysqladmin?-uroot?-proot123?-S? /Data_for_Mysql/3301/data/mysql .sock.3301? shutdown Warning:?Using?a?password?on?the? command ?line?interface?can?be?insecure. 150402?15:44:52?mysqld_safe?mysqld?from?pid? file ?/Data_for_Mysql/3301/data/mysql .pid?ended [1]-??Done????????????????????mysqld_safe?--defaults- file = /Data_for_Mysql/3301/my .cnf?--user=mysql?--basedir= /opt/mysql/mysql-5 .6.15?--datadir= /Data_for_Mysql/3301/data/ |
本文轉自 西索oO 51CTO博客,原文鏈接:http://blog.51cto.com/lansgg/1627717