Use the script one-click to install mysql5.7.x and initialize the database. Start database----MySQL version number: source code mysql5.7.10linux version number: centos6.5 X86_64#!/bin/bashgroup_name=mysqluser_name=mysqlmysqldb_home =/home/mysql/mysqlmysqldb_data_home=/home/mysql/mysql/dataerror_exit=65mysql_version= "mysql-5.7.10" CMAKE_ version= "cmake-3.4.3" boost_version= "Boost_1_59_0" cpu_numbers=$ (cat/proc/cpuinfo |grep "Processor" |wc-l) mysql_id= ' Ifconfig eth0 | grep "inet addr" | Awk-f. ' {print $4} ' | awk ' {print $} ' computer_mem= ' free-m |grep ' MEM ' |awk ' {print $} ' mysql_mem= ' expr $COMPUTER _mem-$COMPUTER _mem/4 ' echo "$MYSQL _mem" echo "=====================================================" echo "Setup MYSQL 5.7.10 on Centos6.5_64bit" echo "Your computer is $CPU _numbers processes, MySQL Memory was $MYSQL _mem M" echo "You'll input MySQL ' s root password a nd MySQL ' s memory "echo" ===================================================== "Sleep 1read-n1-p" is you sure setup[y/n ]? "Answer case $answer in Y | Y) echo echo "Start Setup ...";; N | N) Echoecho "Cancel setup ...." Exit 10;; *) echo echo "error input parameter ..." Exit 11;; Esac#check if User is Rootif [$ (id-u)! = "0"];then echo "error:you must be root to run this script!" Exit 1fi#addgroupif [-Z $ (cat/etc/group|awk-f: ' {print $} ' | grep-w "$GROUP _name")]then groupadd $GROUP _name if ( ($? = = 0)) Then echo "group $GROUP _name Add sucessfully!" Fi else echo "$GROUP _name is Exsits" fi #addUserif [-Z $ (cat/etc/passwd|awk-f: ' {print '} ' | grep-w "$USE _name")]th En adduser-g $GROUP _name $USER _name if (($ = = = 0) then echo "USER $USER _name Add sucessfully!" Fielse echo "$USER _name is Exsits" fi-I in Make gcc-c++ bison-devel ncurses-devel perl perl-devel wgetdo y Um-y install $i Done # # #down Lib:system requirements,cmake>=2.8,boost>=1.59.0rm-rf/tmp/cmake-3.4*wget https:// CMAKE.ORG/FILES/V3.4/${CMAKE_VERSION}.TAR.GZ-P/tmp if (($ = = 0)) then ECHo "CMake DownLoad sucessfully!" else echo "CMake DownLoad failed!" Exit $ERROR _exit Ficd/tmptar xzvf ${cmake_version}.tar.gz cd ${cmake_version}./bootstrapmake && make instally Um install gcc gcc-c++ bzip2 bzip2-devel bzip2-libs python-devel-yrm-rf/tmp/boost_1_59*wget http://downloads.sourcefor GE.NET/PROJECT/BOOST/BOOST/1.59.0/${BOOST_VERSION}.TAR.GZ-P/tmp if ($?
= = 0) then echo "Boost DownLoad sucessfully!" else echo "Boost DownLoad failed!" Exit $ERROR _exit Ficd/tmptar xzvf ${boost_version}.tar.gzcd ${boost_version}./bootstrap.sh./b2 Install#downMySQL RM- rf/tmp/mysql-5.7.* wget http://downloads.mysql.com/archives/get/file/${mysql_version}.tar.gz-p/tmp if (($? = = 0)) Then echo "MySQL DownLoad sucessfully!" else echo "MySQL DownLoad failed!" Exit $ERROR _exit Ficd/tmptar xzvf ${mysql_version}.tar.gzcd ${mysql_version}if [-s/etc/my.cnf]; Then mv/etc/my.cnf/etc/my.cnf. ' Date +%y%m%d%h%m%s '. Bakficmake-dcmake_install_prefix=/home/mysql/mysql-dmysql_da Tadir=/home/mysql/mysql/data-dwith_boost=/usr/local/include/boost-dsysconfdir=/etc-dwith_myisam_storage_engine =1-dwith_innobase_storage_engine=1-dwith_memory_storage_engine=1-dwith_readline=1-dmysql_unix_addr=/var/lib/ Mysql/mysql.sock-dmysql_tcp_port=3306-denabled_local_infile=1-dwith_partItion_storage_engine=1-dextra_charsets=all-ddefault_charset=utf8-ddefault_collation=utf8_general_cimake-j$cpu_ NUMBERS && make install if [-s/etc/my.cnf]; thenmv/etc/my.cnf/etc/my.cnf. ' Date +%y%m%d%h%m%s '. Bakfi#custom set mysql mem#mysql_mem= "800M" #echo-E "please input m Ysql Memory, like 1G, 1M! " #read-P "(Default Memory is:800m):" mysql_mem#if ["$MYSQL _mem" = ""];then# mysql_mem= "800M" #fi #set MYSQL Root Pass Wordecho "===========================" mysqlrootpwd= "root" echo-e "Please input the root password of MySQL:" Read-p "(Defa Ult password:root): "mysqlrootpwdif [$mysqlrootpwd =" "]then mysqlrootpwd=" root "Fiecho" MySQL root "password is $mysq Lrootpwd "echo" ================================= "Mkdir-p $MYSQLDB _home/logtouch $MYSQLDB _home/log/ Mysql-error.logtouch $MYSQLDB _home/log/mysql-slow.logchown-r mysql:mysql $MYSQLDB _homeecho "[MySQL] Default-character-set=utf8[client] #default-character-set=utf8[mysqld] #datadir =/var/lib/mysqlsocket=/var/lib/ Mysql/mysql.sock# disabling symbolic-links is recommended to prevent assorted security Riskssymbolic-links=0port = 3306basedir = $MY Sqldb_homedatadir = $MYSQLDB _data_homepid-file = $MYSQLDB _home/mysql.piduser = Mysqlserver-id = $MYSQL _id#rpl_semi_ Sync_master_enabled=1#rpl_semi_sync_master_timeout=1000#rpl_semi_sync_slave_enabled=1relay_log_purge=0read_ Only=0slave-skip-errors=1396lower_case_table_names = 1character-set-server= Utf8skip-name-resolveskip-external-lockingback_log = 500max_connections = 500max_connect_errors = 2000open_files_ Limit = 65535table_open_cache = Max_allowed_packet = 64m# #thread_concurrency = ' expr $CPU _numbers + $CPU _numbers ' Key_b Uffer_size = 64mread_buffer_size = 64mread_rnd_buffer_size = 16msort_buffer_size = 16mjoin_buffer_size = 16Mtmp_table_ Size = 96mmax_heap_table_size = 96mquery_cache_size = 8mquery_cache_limit = 8mthread_cache_size = 64log_bin = Mysql-binbin Log_format = Mixedbinlog_cache_size = 8msync_binlog = 1max_binlog_cache_size = 8mmax_binlog_size = 500MexpIre_logs_days = 10log_error = $MYSQLDB _home/log/mysql-error.logslow_query_log = 1long_query_time = 1slow_query_log_ File = $MYSQLDB _home/log/mysql-slow.logdefault_storage_engine = innodbinnodb_buffer_pool_size = $MYSQL _meminnodb_ file_per_table = 1innodb_data_home_dir = $MYSQLDB _data_homeinnodb_data_file_path = ibdata1:500m;ibdata2:1g: Autoextendinnodb_log_group_home_dir = $MYSQLDB _homeinnodb_log_file_size = 500minnodb_log_buffer_size = 20Minnodb_ Flush_log_at_trx_commit = 1innodb_print_all_deadlocks = 1[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/ Run/mysqld/mysqld.pid ">/etc/my.cnf## $MYSQLDB _home/scripts/mysql_install_db--defaults-file=/etc/my.cnf-- basedir= $MYSQLDB _home--datadir= $MYSQLDB _data_home--user= $USER _name### #Before MySQL 5.7.6 using mysql_install_db. MySQL 5.7.6 and up using mysqld${mysqldb_home}/bin/mysqld--initialize-insecure--basedir= $MYSQLDB _home--datadir=$ Mysqldb_data_home--user= $USER _NAMECP $MYSQLDB _home/support-files/mysql.server/etc/init.d/mysqlchmod 755/etc/Init.d/mysqlchkconfig--add mysqlchkconfig mysql on/etc/init.d/mysql start cat >>/etc/profile <<eofpath=$ mysqldb_home/bin:\ $PATHexport patheofsource/etc/profilemysqladmin-u root password $mysqlrootpwdecho "set up Successfully!enjoy it .... "Exit 0
Shell script one-click Installation mysql5.7.x