• mysql服务脚本


    #!/bin/bash
    #***************************
    #* copyleft huihui 2015-08-11
    #*****************************
    #*  email: huihui@qq.com
    #*  version:v0.1
    #*****************************
    while true
    do
    
    echo -e"
    #######################################
    A  安装 mysql服务
    B 编辑 mysql服务
    C 开启 mysql服务
    D 关闭mysql服务
    E 卸载 mysql服务
    Q 退出 mysql 服务
    #########################################
    "
    read -p "please input [ABCDEQ]: " i
    install(){
            echo "install mysql"
            yum install gcc gcc-c++  ncurses-devel bison openssl-devel zlib-devel cmake make -y
            cd ~
            tar zxvf mysql-5.5.12.tar.gz
            cd ~/mysql-5.5.12
            cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1  -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all
            make && make install &> /dev/null
    }
    
    edit(){
    	sed -i '$a PATH=$PATH:$HOME/bin:/usr/local/mysql/bin' ~/.bash_profile
            source ~/.bash_profile
            cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
    	cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
                   chmod +x /etc/init.d/mysqld
     
            useradd -M -s /sbin/nologin mysql
    	cd /usr/local/mysql
    	chown -R root .
            chown -R mysql /usr/local/mysql/data
            cd /usr/local/mysql/scripts/
            ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data        
    }
    start(){
              echo "start mysql"
            /etc/init.d/mysqld start
    }
    
    stop(){
    	echo "stop mysql"
            /etc/init.d/mysqld stop
    }
    
    remove(){
            echo "remove mysql"
            rm -fr /usr/local/mysql
    }
    
    case "$i" in
            A|a)
            install
            ;;
            B|b)
            edit
            ;;
            C|c)
            start	
            ;;
            D|d)
            stop
            ;;
            E|e)
            remove
            ;;
            Q|q)
            exit
            ;;
            *)
            echo "input [ABCDEQ],follow the rule"
    esac
    done
    
  • 相关阅读:
    ppt中调整图片位置
    如何理解 Google Protocol Buffer
    g++: error: unrecognized command line option ‘-std=C++11’
    手把手教你如何加入到github的开源世界!
    redis
    maven
    Spring----注释----开启Annotation <context:annotation-config> 和 <context:component-scan>诠释及区别
    JMX学习笔记(一)-MBean
    Redis学习笔记2-redis管道(pipeline)
    Redis学习笔记1-java 使用Redis(jedis)
  • 原文地址:https://www.cnblogs.com/hanfei-1005/p/5708252.html
Copyright © 2020-2023  润新知