標籤:mysql
1.1、shell指令碼自動編譯安裝MySQL
1、進入指令碼固定目錄,編寫自動安裝MySQL指令碼
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
儲存退出
直接執行指令碼就可以了
dos2unix zidong_bianyi-install_mysql.sh
sh zidong_install_mysql.sh
指令碼過程中的錯關於MySQL編譯安裝時報錯解決:
報錯:
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、
解決:
yum -y install ncurses-devel
指令碼成功執行後!
MySQL is installed successfully [ OK ]
shell指令碼自動編譯安裝MySQL