MySQL服务安装之一:一键安装脚本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL服务安装之一:一键安装脚本相关的知识,希望对你有一定的参考价值。
#!/bin/sh #User : bobo365 #Date : 20160127 MAKE(){ if [ `echo $?` -eq 0 ] ;then make else exit fi } MAKE_INS(){ if [ `echo $?` -eq 0 ] ;then make install else exit fi } USER=`whoami` if [ "$USER" != ‘root‘ ] ;then echo "This is not root user。" exit fi if [ -d ‘/usr/local/mysql‘ ] ;then echo "Mysql data directory has been created." else mkdir -p /usr/local/mysql/data fi MYSQL_USER=`egrep -i mysql /etc/passwd` if [ -z "$MYSQL_USER" ] ;then useradd -s /sbin/nologin -M mysql else echo "The mysql user was added" fi yum install -y screen gcc gcc-c++ autoconf automake ncurses-devel sysstat man bash-completion expect bzip2 bzip2-devel wget -O /usr/local/src/cmake-3.3.2.tar.gz https://cmake.org/files/v3.3/cmake-3.3.2.tar.gz tar -zxf /usr/local/src/cmake-3.3.2.tar.gz -C /usr/local/src/ cd /usr/local/src/cmake-3.3.2/ && ./bootstrap MAKE && MAKE_INS wget -O /usr/local/src/mysql-5.6.26.tar.gz http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.6/mysql-5.6.26.tar.gz tar -zxf /usr/local/src/mysql-5.6.26.tar.gz -C /usr/local/src/ cd ../mysql-5.6.26 && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/data/mysql/data -DSYSCONFDIR=/usr/local/mysql/ -DWITH_SSL=bundled -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1 MAKE && MAKE_INS /usr/local/mysql/scripts/mysql_install_db --datadir=/usr/local/mysql/data --user=mysql --basedir=/usr/local/mysql/ mv /etc/my.cnf /etc/my.cnf_bak cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld chmod 755 /etc/init.d/mysqld sed -i ‘s/^# basedir = ...../basedir = \/usr\/local\/mysql/g‘ /etc/my.cnf sed -i ‘s/^# datadir = ...../datadir = \/usr\/local\/mysql\/data/‘ /etc/my.cnf sed -i ‘s/^# port = ...../port = 3306/‘ /etc/my.cnf sed -i ‘s/^# socket = ...../socket = \/tmp\/mysql.sock/‘ /etc/my.cnf /etc/init.d/mysqld start chkconfig --add mysqld && chkconfig mysqld on echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile . /etc/profile PROC=`ps aux|grep mysql |grep -v grep -c` PORT=`netstat -lnp|grep 3306` if [ ! -z "$PORT" ] && [ "$PROC" -ne 0 ] ;then echo "Mysql install and started secussefull" fi
本文出自 “bobo365的运维之路” 博客,请务必保留此出处http://bobo365.blog.51cto.com/1035992/1738847
以上是关于MySQL服务安装之一:一键安装脚本的主要内容,如果未能解决你的问题,请参考以下文章