您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“mysql腳本安裝的示例分析”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“mysql腳本安裝的示例分析”這篇文章吧。
腳本安裝
#!/bin/bash
echo "-----------------------start install mysql----------------------"
#安裝必要的包
yum -y install gcc gcc-c++ ncurses openssl openssl-devel make kernel-devel m4 ncurses-devel libtool*
#創建數據存放文件
mkdir -p /data/dbdata
#檢查mysql組及用戶是否存儲,不存儲則創建
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
#進入安裝目錄進行安裝
cd mysql-5.1.63
echo "configuring mysql,please wait-----------------"
#進行編譯配置prefix為軟件安裝目錄,localstatedir為數據存放目錄等
./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
#更改相關目錄權限
chown -R mysql:mysql /usr/local/mysql
chown -R mysql.mysql /data/dbdata/
#創建系統數據表
/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腳本安裝的示例分析”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。