標籤:一鍵 自動化 安裝 mysql 服務端
聲明
昨夜星辰
部落格:http://yestreenstars.blog.51cto.com/
本文由本人創作,如需轉載,請註明出處,謝謝合作!
目的
一鍵自動化安裝mysql服務端。
環境
OS: CentOS 6.2 32
mysql: 5.6.20
配置
#!/bin/bash# Script Name: One-key Automatic Install MySQL server# Author: yestreenstars# Create Time: 2014-08-18MYSQL_USER_ROOT_PASSWORD="redhat"CMAKE_INSTALL_PREFIX="/usr/local/mysql"MYSQL_DATADIR="/wwwroot/data"DEFAULT_CHARSET="utf8"DEFAULT_COLLATION="utf8_general_ci"echo -n "--Installing related software..."yum -y install gcc gcc-c++ make cmake bison ncurses-devel unzip wget perl > /dev/null 2>&1 && echo "Completed!"echo -n "--Installing mysql-server..."(useradd -M -s /sbin/nologin mysqlmkdir -p $MYSQL_DATADIRchown -R mysql:mysql $MYSQL_DATADIRwget -P /tmp/ http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.20.tar.gztar xzf /tmp/mysql-5.6.20.tar.gz -C /usr/src/cd /usr/src/mysql-5.6.20/cmake -DCMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX -DMYSQL_DATADIR=$MYSQL_DATADIR -DDEFAULT_CHARSET=$DEFAULT_CHARSET -DDEFAULT_COLLATION=$DEFAULT_COLLATIONmakemake install) > /dev/null 2>&1 && echo "Completed!"echo -n "--Initializing..."(cd /usr/local/mysql/./scripts/mysql_install_db --user=mysql --basedir=$CMAKE_INSTALL_PREFIX --datadir=$MYSQL_DATADIR/bin/cp -f $PWD/support-files/mysql.server /etc/init.d/mysqld/bin/cp -f $PWD/support-files/my-default.cnf /etc/my.cnfecho "PATH=$CMAKE_INSTALL_PREFIX/bin/:$PATH" >> /etc/profilechkconfig --add mysqldchkconfig mysqld onservice mysqld start$CMAKE_INSTALL_PREFIX/bin/mysqladmin -uroot password $MYSQL_USER_ROOT_PASSWORD) > /dev/null 2>&1 && echo "Completed!"
運行完以上指令碼後需手動運行一下以下命令:
source /etc/profile
本文出自 “昨夜星辰” 部落格,請務必保留此出處http://yestreenstars.blog.51cto.com/1836303/1541562