#!/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
网友评论