shell脚本自动编译安装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  ]


猜你喜欢

转载自blog.51cto.com/13673885/2124304