一键自动化安装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-18 MYSQL_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 mysql mkdir -p $MYSQL_DATADIR chown -R mysql:mysql $MYSQL_DATADIR wget -P /tmp/ http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.20.tar.gz tar 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_COLLATION make make 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.cnf echo "PATH=$CMAKE_INSTALL_PREFIX/bin/:$PATH" >> /etc/profile chkconfig --add mysqld chkconfig mysqld on service 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
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。