shell指令碼自動編譯安裝MySQL

來源:互聯網
上載者:User

標籤: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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.