美文网首页MySql
shell编写二进制安装mysql_5.7

shell编写二进制安装mysql_5.7

作者: s1mple | 来源:发表于2021-05-19 17:18 被阅读0次
    #!/bin/bash
    # install mysql 5.7.26
    # by 杨进!
    
    basedir=/usr/local
    nametar=mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
    
    cd /usr/local
    yum -y install wget
    wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
    tar -zxvf $nametar
    mv mysql-5.7.26-linux-glibc2.12-x86_64 mysql
    #添加用户组
    groupadd mysql
    #添加用户mysql 到用户组mysql
    useradd -g mysql mysql
    
    cd mysql
    chown -R mysql:mysql ./
    #安装并初始化
    ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
    chown -R root .
    chown -R mysql data
    
    #设置启动
    cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
    chmod +x /etc/rc.d/init.d/mysqld
    chkconfig --add mysqld
    chkconfig --list mysqld
    cp /usr/local/mysql/bin/my_print_defaults /usr/bin/
    mkdir -p /var/lib/mysql
    chown -R mysql:mysql /var/lib/mysql
    service mysqld start
    

    相关文章

      网友评论

        本文标题:shell编写二进制安装mysql_5.7

        本文链接:https://www.haomeiwen.com/subject/oqnpjltx.html