Shell install MySQL binary package

Source: Internet
Author: User

Now unzip the MySQL binary package, a little configuration, you can use, installation speed, installation to practice the best, haha

The script just installs the binary MySQL package, MY.CNF only modified the simple options, not too much to set up, if friends use my script to install as a online environment, you need to change the variable to the content you want, my.cnf you have to configure according to your production environment, the installation package is downloaded from the official website, now it seems that the wall to download

Official website: http://dev.mysql.com/downloads/mysql/

#!/bin/bash#-------------------------------#thisInstallJust forTest ues#WriteOn the- One- -#Writeby xuanzhi#------------------------------#定义变量soft_path=/usr/local/Srcmysql_pack=mysql-5.5. +-linux2.6-x86_64.Tar. Gzmysql_version=`Echo "mysql-5.5.40-linux2.6-x86_64.tar.gz"|Cut-D--F1,2' Mysql_user=Mysql2mysql_port=3308mysql_passwd=123456Install_path=/usr/Localmysql_path=/usr/local/${mysql_version}mysql_data_path=/data/${mysql_version}/data# Create user, empower, install Groupadd ${mysql_user}if[$?-ne0 ] Then  Echo "This user ${mysql_user} is exist!!"Exit1fiUseradd-R-g ${mysql_user} ${mysql_user}cd ${soft_path}if[ ! -e ${mysql_pack}] Then  Echo "Install pack is not exist!!"Exit1fiTarZXVF ${mysql_pack}-C ${install_path}cd ${install_path}&&MV${mysql_version}-*${mysql_version}Chown-R Root:${mysql_user} ${mysql_path}cd ${mysql_path}&&CPSUPPORT-FILES/MY-LARGE.CNF ${mysql_path}/my.cnfmkdir-p/data/${mysql_version}Chown-R ${mysql_user}:${mysql_user}/data/${mysql_version} #修改my. CNFsed-I."/3306/{x;s/^/./;/^.\{2\}$/{x;s/3306/${mysql_port}/;b};x}"${mysql_path}/my.cnfsed-I."/socket/{x;s/^/./;/^.\{2\}$/{x;s#/tmp/mysql.sock#/data/${mysql_version}/mysql.sock#;b};x}"${mysql_path}/my.cnfsed-I."/${mysql_port}/a\datadir = ${mysql_data_path}"${mysql_path}/my.cnfsed-I."/${mysql_port}/a\basedir = ${mysql_path}"${mysql_path}/my.cnfsed-I."/${mysql_port}/a\use = ${mysql_user}"${mysql_path}/my.cnfsed-I."/innodb_buffer_pool_size/s/^#//"${mysql_path}/my.cnf# initializing CD ${mysql_path}Yum InstallLibaio-yscripts/mysql_install_db--user=${mysql_user}--defaults-file=${mysql_path}/my.cnfif[$?-ne0 ] Then  Echo-E"\e[1;31m[mysql Install init failure ...] \e[0m"Exit1fi#添加启动关闭脚本Cat>>shutdown_mysql.SH<<eof#!/bin/Bash${mysql_path}/bin/mysqladmin--defaults-file=${MYSQL_PATH}/MY.CNF-UROOT-P${MYSQL_PASSWD}-s/data/${mysql_version}/Mysql.sock shutdowneofCat>>start_mysql.SH<<eof#! /bin/SHnohup ${mysql_path}/bin/mysqld_safe--defaults-file=${MYSQL_PATH}/MY.CNF >> ${mysql_path}/start_stop.log2>&1&eof# start MySQLchmod+x Shutdown_mysql.SHStart_mysql.SH&&SHStart_mysql.SHSleep  -PS-aux |grep-Vgrep|grep${mysql_port} &>/dev/NULLif[$?-ne0 ] Then   Echo-E"\e[1;31m[mysql start failure ...] \e[0m"Exit1Else    Echo-E"\e[1;32m[mysql start secessful]\e[0m"fi#修改密码 ${mysql_path}/bin/mysqladmin-uroot Password"${MYSQL_PASSWD}"-s/data/${mysql_version}/mysql.sock

If the script has any problems, I hope you can point out, let me know more of their shortcomings, thank you ^.^

Shell install MySQL binary package

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.