您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“mysql腳本安裝的示例分析”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“mysql腳本安裝的示例分析”這篇文章吧。
腳本安裝
#!/bin/bash
echo "-----------------------start install mysql----------------------"
#安裝必要的包
yum -y install gcc gcc-c++ ncurses openssl openssl-devel make kernel-devel m4 ncurses-devel libtool*
#創(chuàng)建數(shù)據(jù)存放文件
mkdir -p /data/dbdata
#檢查mysql組及用戶(hù)是否存儲(chǔ),不存儲(chǔ)則創(chuàng)建
if [ `grep "mysql" /etc/passwd | wc -l` -eq 0 ];then
echo "adding user mysql"
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
else
echo "mysql user is exist"
fi
#下載mysql5.1tar包
wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.63.tar.gz
echo "tar xzvf mysql-5.1.63.tar.gz"
#解壓tar包
tar xzvf mysql-5.1.63.tar.gz
#進(jìn)入安裝目錄進(jìn)行安裝
cd mysql-5.1.63
echo "configuring mysql,please wait-----------------"
#進(jìn)行編譯配置prefix為軟件安裝目錄,localstatedir為數(shù)據(jù)存放目錄等
./configure '--prefix=/usr/local/mysql' '--localstatedir=/data/dbdata/' '--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock' '--with-charset=utf8'
'--with-extra-charsets=complex' '--with-pthread' '--enable-thread-safe-client' '--with-ssl' '--with-client-ldflags=-all-static'
'--with-mysqld-ldflags=-all-static' '--with-plugins=partition,federated,innobase,csv,blackhole,myisam,innodb_plugin,heap,archive'
'--enable-shared' '--enable-assembler'
if [ $? -ne 0 ];then
echo "configure filed ,please check it out!"
exit 1
fi
#編輯
echo "make mysql, please wait for 20 minutes"
make
if [ $? -ne 0 ];then
echo "make filed ,please check it out!"
exit 1
fi
#編譯安裝
make install
#更改相關(guān)目錄權(quán)限
chown -R mysql:mysql /usr/local/mysql
chown -R mysql.mysql /data/dbdata/
#創(chuàng)建系統(tǒng)數(shù)據(jù)表
/usr/local/mysql/bin/mysql_install_db --user=mysql
cp ../my.cnf /etc/my.cnf
cp /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
cp /usr/local/mysql/bin/mysql* /usr/bin/
echo "mysql starting"
/etc/rc.d/init.d/mysqld start
if [ $? -ne 0 ];then
echo "mysql start filed ,please check it out!"
else
echo "mysql start successful,congratulations!"
fi
以上是“mysql腳本安裝的示例分析”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。