1,mysql Installation Scripts
1#!/bin/Bash2Rsync='10.39.2.120::wenhui/database/install'3Cmake='cmake-2.8.6.tar.gz'4Mysql='mysql-5.5.24.tar.gz'5Mysql_dir='/usr/local/mysql55'6Mysql_datadir='/data1/mysqldata/mysql3306'7 8 function Main () {9User=' WhoAmI 'Ten if["$user"!="Root" ]; Then OneEcho"Please use the root to execute this script" AExit1 - fi - themodule=$1 -module_type=$2 - Case " $" inch - cmake) + Install_cmake - ;; + MySQL) A install_mysql $module _type at ;; -*) -Echo"USAGE: $ module[cmake|mysql] module_type[full|libmysql|mysqlclient]" - Esac - } - in #install CMake - function Install_cmake () { toEcho"Begin install CMake"; Sleep1 +Echo"get tar from $RSYNC" -Eval"rsync-avzp $RSYNC/$CMAKE." theDir= ' echo $CMAKE | Perl-pe's/\q.tar.gz\e$//g'` *Eval"test-e $dir && rm-rf $dir" $Eval"TAR-ZXVF $CMAKE"Panax NotoginsengEcho"CD to $dir" -Eval"CD $dir" the./Configure +Make &&Make Install A CD.. the } + - #install MySQL $ function Install_mysql () { $Ld_path='/etc/ld.so.conf.d/mysql.conf' -Install_type=' Full' - if[" $"!="" ]; Then theinstall_type=$1 - fiWuyi theEcho"begin install MySQL $INSTALL _type"; Sleep1 -Echo"get tar from $RSYNC" WuEval"rsync-avzp $RSYNC/$MYSQL." -Dir= ' echo $MYSQL | Perl-pe's/\q.tar.gz\e$//g'` AboutEval"test-d $dir && rm-rf $dir" $Eval"TAR-ZXVF $MYSQL" -Echo"CD to $dir" -Eval"CD $dir" - if["$INSTALL _type"==" Full" ]; Then AEval"useradd mysql-s/sbin/nologin" +Eval"cmake-dcmake_install_prefix= $MYSQL _dir \ the-dmysql_unix_addr=/tmp/Mysql.sock --ddefault_charset=UTF8 $-ddefault_collation=Utf8_general_ci the-dwith_myisam_storage_engine=1 the-dwith_innobase_storage_engine=1 the-dwith_memory_storage_engine=1 the-dwith_readline=1 --denabled_local_infile=1 in-dmysql_datadir==$MYSQL _datadir the-dmysql_user=MySQL the-dmysql_tcp_port=3306 About-dwith_partition_storage_engine=1 the-dextra_charsets= All the-dwith_extra_charsets= All the " +Make &&Make Install - the #copy Configure fileBayiScript_dir="$MYSQL _dir/start" thetest-d $SCRIPT _dir | | mkdir-P $SCRIPT _dir theEval"rsync-avzp $RSYNC/my.cnf $SCRIPT _dir" -Eval"rsync-avzp $RSYNC/init.sh $SCRIPT _dir" - theelif ["$INSTALL _type"=="Libmysql" ]; Then theEval"cmake-dcmake_install_prefix= $MYSQL _dir \ the-dwithout_server= on the " -Make &&Make Install the theelif ["$INSTALL _type"=="mysqlclient" ]; Then theEval"cmake-dcmake_install_prefix= $MYSQL _dir \94 " theMake Mysqlclient libmysql &&Make Install the fi the 98Echo"Add bin path TO/ETC/BASHRC" AboutEcho"">>/etc/BASHRC -Echo"#mysql envirment">>/etc/BASHRC101Echo"export path=\ $PATH: $MYSQL _dir/bin">>/etc/BASHRC102Echo"add LD path to $LD _path"103Echo"$MYSQL _dir/lib">$LD _path104 Ldconfig the }106 107Main $1$2View Code
Main service: Mysql-server MySQL Mysql-devel
[Email protected] ~]# sh/usr/local/mysql55/start/init.sh 3306 #创建启动脚本
* [[email protected] ~]# head install.sh
..............
Mysql_dir= '/usr/local/mysql55 ' # default database installation path
Mysql_datadir= '/data0/mysqldata/mysql3306 ' # default database storage path
...............
* [[email protected] ~]# sh install.sh mysql libmysql # install libmysqlclient for Perl,python even MySQL database use
= = = Installation details ======
# CMake
Tar zxvf cmake-2.8.6.tar.gz
CD cmake-2.8.6
./configure
Make && make install
# Mysql
Tar zxvf mysql-5.5.24.tar.gz
cd mysql-5.5.24
cmake-dcmake_install_prefix=/usr/local/mysql55 \
-dmysql_unix_addr=/tmp/mysql.sock \
-ddefault_charset=utf8 \
-ddefault_collation=utf8_general_ci \
- dwith_myisam_storage_engine=1 \
-dwith_innobase_storage_engine=1 \
-dwith_memory_storage_engine=1 \
- dwith_readline=1 \
-denabled_local_infile=1 \
-dmysql_datadir==/data0/mysqldata/mysql3306 \
-DMYSQL_USER =mysql \
-dmysql_tcp_port=3306 \
-dwith_partition_storage_engine=1 \
-dextra_charsets=all \
-DWITH_ Extra_charsets=all \
make && make install
Database Default storage path:/var/lib/mysql
MySQL Learning Journey