Centos 5.8 Install MySQL 5.5.25 source pack with Shell script one key

Source: Internet
Author: User
Tags mkdir mysql version pack sleep centos mysql database

Recently in the study of MySQL cluster, at least to install 2 or more MySQL database installation, operation is cumbersome and time-consuming, today, according to the installation steps to write a shell script, just execute the following script can quickly install the MySQL database, For beginners or want to learn the MySQL cluster of friends is very convenient, that is, time-saving, and labor-saving.

Operating system and its MySQL configuration file description:

Linux system: Centos5.8

Mysql:mysql-5.5.25tar.gz Source Pack

Installation directory:/usr/local/mysql/

Data directory:/data/mysql/3306/data/

Binary log:/data/msyql/3306/binlog/

Relay log:/data/mysql/3306/relaylog/

Configuration file:/data/mysql/3306/my.cnf

Mysql.sock File:/data/mysql/3306/mysql.sock

The following is a key I wrote a MySQL database script, if there are wrong places please advise.

[root@db148 sh]# cat mysql_install_new_version.sh


#!/bin/bash


#创作日期: 2012.6.16


#作者: Zhang


#Mysql install directory and configuration files.


mysql_dir= "/data/software"


data_dir= "/data/mysql/3306/data"


base_dir= "/usr/local/mysql"


echo "Please input MySQL version:"


Read VERSION


echo "Your MySQL version is mysql-$VERSION. tar.gz"


if [e "$MYSQL _dir/mysql-$VERSION. tar.gz"]


then


echo "Please waitting ..."


Sleep 3


#Install MySQL package dependent.


yum-y Install gcc gcc-c++ gcc-g77 autoconf automake OpenSSL zlib* fiex** libxml* \


ncurses-devel libmcrypt* libtool-ltdl-devel* &&


#Install CMake.


echo "The system is to be installed Cmake,please waitting ..."


Sleep 3


tar-zxvf $MYSQL _dir/cmake-2.8.8.tar.gz-c $MYSQL _dir &&


CD $MYSQL _dir/cmake-2.8.8 &&


./configure \


--prefix=/usr/local/cmake &&


make && make install &&


#creating MySQL account and group.


/usr/sbin/groupadd MySQL &&


/usr/sbin/useradd-s/sbin/nologin-g mysql-m MySQL &&


#Install MySQL.


tar-zxvf $MYSQL _dir/mysql-$VERSION. tar.gz-c $MYSQL _dir


CD $MYSQL _dir/mysql-$VERSION


echo "path= $PATH:/usr/local/cmake/bin" >>/etc/profile && source/etc/profile


cmake \


$MYSQL _dir/mysql-$VERSION


-dcmake_install_prefix=/usr/local/mysql \


-dysql_tcp_port=3306 \


-dmysql_datadir= $DATA _dir \


-dmysql_unix_addr=/data/mysql/3306/mysql.sock \


-dwith_myisam_storage_engine=1 \


-dwith_innobase_storage_engine=1 \


-ddefault_charset=utf8 \


-ddefault_collation=utf8_general_ci \


-dextra_charsets=all \


-dwith_debug=0


make && make install &&


mkdir-p $DATA _dir


Mkdir-p ' dirname $DATA _dir '/binlog


mkdir-p ' dirname $DATA _dir '/relaylog


CP $MYSQL _dir/mysql-$VERSION/support-files/my-small.cnf.sh ' dirname $DATA _dir '/my.cnf


CP $MYSQL _dir/mysql-$VERSION/support-files/mysql.server.sh/etc/init.d/mysqld


chmod +x/etc/init.d/mysqld


sed-i ' s/^basedir=/basedir=\/usr\/local\/mysql/'/etc/init.d/mysqld


sed-i ' s/^datadir=/datadir=\/data\/mysql\/3306/'/etc/init.d/mysqld


sed-i ' s/' @HOSTNAME @ '/db148/'/etc/init.d/mysqld


sh/usr/local/mysql/scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql--datadir= $DATA _dir & &


/etc/init.d/mysqld Start


Else


echo "Your input MySQL version isn't in $MYSQL _dir"


fi

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.