1.1. Shell script automatically compiles and installs MySQL
1, enter the script fixed directory, write the automatic installation MySQL script
cd/server/scripts/
Vim zidong_bianyi-install_mysql.sh
#!/bin/bash
. /etc/init.d/functions
Mysql_tool_dir= "/USR/LOCAL/SRC"
Mysql_install_dir= "/application/mysql"
mysql_version= "5.1.73"
echo "-------step 1:add mysql user--------"
Useradd-m-s/sbin/nologin MySQL
Sleep 1
echo "-------step 2:download mysql-------"
Mkdir-p ${mysql_tool_dir}
CD ${mysql_tool_dir}
[!-f mysql-${mysql_version}.tar.gz] && \
wget http://mirrors.163.com/mysql/downloads/mysql-5.1/mysql-${mysql_version}.tar.gz
echo "-------step 3:install mysql-------"
CD ${mysql_tool_dir}
Tar zxf mysql-${mysql_version}.tar.gz
CD Mysql-${mysql_version}
Mkdir-p ${mysql_install_dir}
./configure \
--prefix=${mysql_install_dir} \
--with-unix-socket-path=${mysql_install_dir} \
--localstatedir=${mysql_install_dir}/data \
--enable-assembler \
--enable-thread-safe-client \
--with-mysqld-user=mysql \
--with-big-tables \
--without-debug \
--with-pthread \
--enable-assembler \
--with-extra-charsets=complex \
--with-readline \
--WITH-SSL \
--with-embedded-server \
--enable-local-infile \
--with-plugins=partition,innobase \
--with-plugin-plugin \
--with-mysqld-ldflags=-all-static \
--with-client-ldflags=-all-static
If [$?-ne 0];then
Action "MySQL Configure"/bin/false
Exit 1
Fi
Make
If [$?-ne 0];then
Action "MySQL make"/bin/false
Exit 1
Fi
Make install
If [$?-ne 0];then
Action "MySQL make install"/bin/false
Exit 1
Fi
Action "MySQL is installed successfully"/bin/true
Save exit
Execute the script directly.
Dos2unix zidong_bianyi-install_mysql.sh
SH zidong_install_mysql.sh
Mistakes in the scripting process about MySQL compile install times error Resolution:
Error:
Checking for tgetent in-lncursesw ... no
Checking for tgetent in-lncurses ... no
Checking for tgetent in-lcurses ... no
Checking for tgetent in-ltermcap ... no
Checking for tgetent in-ltinfo ... no
Checking for termcap functions Library ... configure:error:No curses/termcap Library found,
Solve:
Yum-y Install Ncurses-devel
After the script executes successfully!
MySQL is installed successfully [OK]
Shell script automatically compiles and installs MySQL