MySQL 5.5.40 automated installation script

Source: Internet
Author: User

MySQL 5.5.40 automated installation script

After learning the Linux Shell script for two weeks, I finally wrote a MySQL automated installation script. With the full-day test today, MySQL 5.5.40 can be installed normally. Other versions have not been tested. Here, we will share with you. Please give me some advice.

The premise for executing this script is:

Environment Introduction:

1. RedHat 6.3x64, minimal installation
2. RAM: 2G, HD: 30G
3. Disable selinux.
4. Configure the yum source (I use the source configured by myself)
5. enable ssh, configure iptables, and allow remote access.
6. Required software and documents:

Cmake-2.8.10.1.tar.gz
Bison-3.0.tar.gz
Zlib-1.2.7.tar.gz
Mysql-5.5.40.tar.gz
My. cnf // file shared by the instructor

Script content:

#! /Bin/bash

Echo "step one: create folder and mount packages"

If [-d/mnt/share]

Then

Echo "find it, don't need to create it ."

 


Else

Mkdir-p/mnt/share

If [[$? = 0]

Then

Echo "create it successfully! "

Else

Echo "can't create this folder! Pls check out! "

Fi

Mount-t cifs-o username = swen02, password = autozhao01! // 172.16.11.20/LAMP-all-software/mnt/share

Fi

 


Echo "step two: create mysql installation path"

 


If [-d/project/class2]

Then

Echo "find it, don't need to create it ."

Else

Mkdir-p/project/class2/

If [[$? = 0]

Then

Echo "create it successfully! "

Else

Echo "can't create this floder! Pls check out! "

Fi

Fi

 


Echo "step three: copy packages to the folder"

 


Cp/mnt/share/cmake-2.8.10.1.tar.gz/project/class2/

Cp/mnt/share/bison-3.0.tar.gz/project/class2/

Cp/mnt/share/zlib-1.2.7.tar.gz/project/class2/

Cp/mnt/share/mysql-5.5.40.tar.gz/project/class2/

Cp/mnt/share/my. cnf/project/class2/

 


Echo "step four: install base packages"

 


Yum-y install gcc-c ++ gcc-g77 autoconf automake zlib * fiex * libxml * ncurses-devel libmcrypt * libtool-ltdl-devel *

 


Cd/project/class2

Tar-xzvf cmake-2.8.10.1.tar.gz

Cd cmake-2.8.10.1

./Bootstrap

Make & make install

If [[$? = 0]

Then

Echo "good job! "

Else

Echo "sorry, pls check out! "

Exit 1

Fi

Cd ..

Tar-zxvf bison-3.0.tar.gz

Cd bison-3.0

./Configure

Make & make install

If [[$? = 0]

Then

Echo "good job! "

Else

Echo "sorry, pls check out! "

Exit 1

Fi

Cd ..

Tar-zxvf zlib-1.2.7.tar.gz

Cd zlib-1.2.7

./Configure

Make & make install

Cd ..

If [[$? = 0]

Then

Echo "good job! "

Else

Echo "sorry, pls check out! "

Exit 1

Fi

 

 

 

Echo "step five: configure system referenc"

 


FLAGS = "-O3-g-fno-exceptions-static-libgcc-fno-omit-frame-pointer-fno-strict-aliasing"

CXX = g ++

CXXFLAGS = "-O3-g-fno-exceptions-fno-rtti-static-libgcc-fno-omit-frame-pointer-fno-strict-aliasing"

Export CFLAGS CXX CXXFLAGS

 


Echo "step six: begin to install mysql"

 


Groupadd mysql

Useradd-r-g mysql

Tar-zxvf mysql-5.5.40.tar.gz

Cd mysql-5.5.40

Cmake-DCMAKE_INSTALL_PREFIX =/project/class2/mysql

Make

Make install

If [[$? = 0]

Then

Echo "good job! "

Else

Echo "sorry, pls check out! "

Exit 1

Fi

Cd ..

 


# Create folder and initial new db

Mkdir./mysql/run

Mkdir./mysql/log

Chown-R mysql. mysql/project/class2/mysql

Rm-rf/project/class2/mysql/data /*

./Mysql/scripts/mysql_install_db -- datadir =/project/class2/mysql/data -- user = mysql -- basedir =/project/class2/mysql

 


# Modify my. cnf and copy new one

 


Sed's/default-character-set = gbk/default-character-set = utf8/'my. cnf | sed's/skip-ssl/# skip-ssl/'>. /mysql/my. cnf

Chown-R mysql. mysql/project/class2/mysql/my. cnf

 


# Creat ln

 


Ln-s/project/class2/mysql/run/mysql. sock/tmp/mysql. sock

 


Mv/root/. bash_profile/root/. bash_profile.bak

 


/Bin/sed '/export PATH/I \ export PATH = "$ PATH":/project/class2/mysql/bin/'/root/. bash_profile.bak>/root/. bash_profile

 


# Start mysql service

./Mysql/bin/mysqld_safe -- defaults-file =/project/class2/mysql/my. cnf &

 


# Waitting for service to be started

Signal = 0

While [["$ signal" = 0]

Do

If [-z "'grep' Source distribution '/project/class2/mysql/log/alert. log'"]

Then

Echo "not found it"

Sleep 30

Else

Echo "found it"

Let signal + = 1

Fi

Done

 


# Logout and relogin, new PATH will be take effect.

Kill-9 $ PPID

-------------------------------------- Split line --------------------------------------

Install MySQL in Ubuntu 14.04

MySQL authoritative guide (original book version 2nd) Clear Chinese scan PDF

Ubuntu 14.04 LTS install LNMP Nginx \ PHP5 (PHP-FPM) \ MySQL

Build a MySQL Master/Slave server in Ubuntu 14.04

Build a highly available distributed MySQL cluster using Ubuntu 12.04 LTS

Install MySQL5.6 and Python-MySQLdb in the source code of Ubuntu 12.04

MySQL-5.5.38 universal binary Installation

-------------------------------------- Split line --------------------------------------

This article permanently updates the link address:

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.