一键安装MySQL5.1.45,全自动安装MySQL SHELL程序(编译安装)

一.问题来源

安装MySQL如果手动安装一台还可以,但安装多台,手动安装很麻烦,需要编写一个shell程序 install_mysql.sh来进行安装


二.程序说明

将MySQL5.1.45安装到了 /home/longxibendi/mysql/usrl/local/mysql

数据文件以及日志文件设置在了 /home/longxibendi/mysql/3309/

配置文件my.cnf 在   /home/longxibendi/mysql/3309

端口使用  3309


三.源程序 install_mysql.sh

  1. #!/bin/bash 
  2. #author longxibendi 
  3. #function install MySQL5.1.45 
  4.  
  5.  
  6.  
  7. ###################################### configure and install  ##################################################### 
  8. mkdir -p /home/longxibendi/mysql/usr/local/mysql 
  9. cd  
  10. mkdir mysql 
  11. cd mysql 
  12. wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.45.tar.gz 
  13.  
  14. tar zxvf mysql-5.1.45.tar.gz 
  15. cd mysql-5.1.45 
  16.  
  17.  
  18.  
  19.  
  20. ./configure --prefix=/home/longxibendi/mysql/usr/local/mysql --without-debug --without-bench --enable-thread-safe-client --enable-assembler --enable-profiling --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-charset=latin1 --with-extra-charset=utf8,gbk --with-innodb --with-mysqld-user=longxibendi --without-embedded-server --with-server-sufix=community  --with-unix-socket-path=/home/longxibendi/mysql/usr/local/mysql/sock/mysql.sock  --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl  --with-plugins=partition,heap,innobase,myisam,myisammrg,csv 
  21. make -j `cat /proc/cpuinfo | grep 'model name' | wc -l ` && make install 
  22.  
  23.  
  24.  
  25. ###################################### set log and data storage path  ##################################################### 
  26.  
  27. chmod +w /home/longxibendi/mysql/usr/local/mysql 
  28. mkdir  -p /home/longxibendi/mysql/3309/data/ 
  29. mkdir  -p /home/longxibendi/mysql/3309/binlog/ 
  30. mkdir  -p /home/longxibendi/mysql/3309/relaylog/ 
  31.  
  32.  
  33. ###################################### create data file ##################################################### 
  34.  
  35. /home/longxibendi/mysql/usr/local/mysql/bin/mysql_install_db --basedir=/home/longxibendi/mysql/usr/local/mysql --datadir=/home/longxibendi/mysql/3309/data --user=longxibendi 
  36.  
  37.  
  38. ####################################### create my.cnf  profile ##################################################### 
  39.  
  40. echo " 
  41. [client] 
  42. character-set-server = utf8 
  43. port    = 3309 
  44. socket  = /home/longxibendi/mysql/usr/local/mysql/sock/mysql.sock 
  45.  
  46. [mysqld] 
  47. character-set-server = utf8 
  48. replicate-ignore-db = mysql 
  49. replicate-ignore-db = test 
  50. replicate-ignore-db = information_schema 
  51. user    = mysql 
  52. port    = 3309 
  53. socket  = /home/longxibendi/mysql/usr/local/mysql/sock/mysql.sock 
  54. basedir = /home/longxibendi/mysql 
  55. datadir = /home/longxibendi/mysql/3309/data 
  56. log-error = /home/longxibendi/mysql/3309/mysql_error.log 
  57. pid-file = /home/longxibendi/mysql/3309/mysql.pid 
  58. open_files_limit    = 10240 
  59. back_log = 600 
  60. max_connections = 5000 
  61. max_connect_errors = 6000 
  62. table_cache = 614 
  63. external-locking = FALSE 
  64. max_allowed_packet = 16M 
  65. sort_buffer_size = 1M 
  66. join_buffer_size = 1M 
  67. thread_cache_size = 300 
  68. #thread_concurrency = 8 
  69. query_cache_size = 20M 
  70. query_cache_limit = 2M 
  71. query_cache_min_res_unit = 2k 
  72. default-storage-engine = MyISAM 
  73. thread_stack = 192K 
  74. transaction_isolation = READ-COMMITTED 
  75. tmp_table_size = 20M 
  76. max_heap_table_size = 20M 
  77. long_query_time = 3 
  78. log-slave-updates 
  79. log-bin = /home/longxibendi/mysql/3309/binlog/binlog 
  80. binlog_cache_size = 4M 
  81. binlog_format = MIXED 
  82. max_binlog_cache_size = 8M 
  83. max_binlog_size = 20M 
  84. relay-log-index = /home/longxibendi/mysql/3309/relaylog/relaylog 
  85. relay-log-info-file = /home/longxibendi/mysql/3309/relaylog/relaylog 
  86. relay-log = /home/longxibendi/mysql/3309/relaylog/relaylog 
  87. expire_logs_days = 30 
  88. key_buffer_size = 10M 
  89. read_buffer_size = 1M 
  90. read_rnd_buffer_size = 6M 
  91. bulk_insert_buffer_size = 4M 
  92. myisam_sort_buffer_size = 8M 
  93. myisam_max_sort_file_size = 20M 
  94. myisam_repair_threads = 1 
  95. myisam_recover 
  96.  
  97. interactive_timeout = 120 
  98. wait_timeout = 120 
  99.  
  100. skip-name-resolve 
  101. #master-connect-retry = 10 
  102. slave-skip-errors = 1032,1062,126,1114,1146,1048,1396 
  103.  
  104. #master-host     =   192.168.1.2 
  105. #master-user     =   username 
  106. #master-password =   password 
  107. #master-port     =  3309 
  108.  
  109. server-id = 1 
  110.  
  111. innodb_additional_mem_pool_size = 16M 
  112. innodb_buffer_pool_size = 20M 
  113. innodb_data_file_path = ibdata1:56M:autoextend 
  114. innodb_file_io_threads = 4 
  115. innodb_thread_concurrency = 8 
  116. innodb_flush_log_at_trx_commit = 2 
  117. innodb_log_buffer_size = 16M 
  118. innodb_log_file_size = 20M 
  119. innodb_log_files_in_group = 3 
  120. innodb_max_dirty_pages_pct = 90 
  121. innodb_lock_wait_timeout = 120 
  122. innodb_file_per_table = 0 
  123.  
  124. #log-slow-queries = /home/longxibendi/mysql/3309/slow.log 
  125. #long_query_time = 10 
  126.  
  127. [mysqldump] 
  128. quick 
  129. max_allowed_packet = 32M 
  130.  
  131. " > /home/longxibendi/mysql/3309/my.cnf 
  132.  
  133.  
  134. ############################### solve  bug  http://bugs.mysql.com/bug.php?id=37942  ############################################# 
  135.  
  136. mkdir -p /home/longxibendi/mysql/share/mysql/english/ 
  137. cp /home/longxibendi/mysql/usr/local/mysql/share/mysql/english/errmsg.sys /home/longxibendi/mysql/share/mysql/english/ 
  138.  
  139. ############################### start MySQL Server  ############################################# 
  140. /bin/sh /home/longxibendi/mysql/usr/local/mysql/bin/mysqld_safe --defaults-file=/home/longxibendi/mysql/3309/my.cnf 2>&1 > /dev/null & 
  141. ############################### try use MySQL Server  ############################################# 
  142. /home/longxibendi/mysql/usr/local/mysql/bin/mysql -u root -p -S /home/longxibendi/mysql/usr/local/mysql/sock/mysql.sock -P3309 -h127.0.0.1 -e "show databases;" 

四.成功安装结果

当安装完成之后,直接回车,就可以看到 以下信息

information_schema

mysql

test

声明:本文档可以随意更改,但必须署名原作者

作者:凤凰舞者 qq:578989855

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值