MySQL自动化安装脚本

 该脚本简单实现MySQL5.7.21的自动化安装,比较简单,但是基本能实现本公司MySQL的快速部署(滑稽脸)

 

#!/bin/bash
# author:颜海航
# version:1.0
# date:2019-04-25
echo "#############################  MySQL  installing..........########################"

echo "-----config my.cnf-----"
mv /etc/my.cnf /etc/my.cnf_`date +%Y%m%d`
SERVER_ID=`ifconfig eth0  |grep inet |awk '{print $2}'|awk -F. '{print $3$4}'`
Mem=`free -m |grep Mem |awk '{print $2}'`
SIZE=$[Mem*1/2]
cat >>/etc/my$ipaddr.cnf<> /etc/profile
source /etc/profile

echo  "-----initialize MySQL-----"
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/server/mysql_data/

echo  "-----start  MySQL-----"
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
/etc/init.d/mysqld start

#!/bin/bash
# author:颜海航
# version:1.0
# date:2019-04-25
echo "#############################  MySQL  installing..........########################"

echo "-----config my.cnf-----"
mv /etc/my.cnf /etc/my.cnf_`date +%Y%m%d`
SERVER_ID=`ifconfig eth0  |grep inet |awk '{print $2}'|awk -F. '{print $3$4}'`
Mem=`free -m |grep Mem |awk '{print $2}'`
SIZE=$[Mem*1/2]
cat >>/etc/my$ipaddr.cnf<> /etc/profile
source /etc/profile

echo  "-----initialize MySQL-----"
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/server/mysql_data/

echo  "-----start  MySQL-----"
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
/etc/init.d/mysqld start

#!/bin/bash
# author:颜海航
# version:1.0
# date:2019-04-25
echo "#############################  MySQL  installing..........########################"

echo "-----config my.cnf-----"
mv /etc/my.cnf /etc/my.cnf_`date +%Y%m%d`
SERVER_ID=`ifconfig eth0  |grep inet |awk '{print $2}'|awk -F. '{print $3$4}'`
Mem=`free -m |grep Mem |awk '{print $2}'`
SIZE=$[Mem*1/2]
cat >>/etc/my$ipaddr.cnf<> /etc/profile
source /etc/profile

echo  "-----initialize MySQL-----"
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/server/mysql_data/

echo  "-----start  MySQL-----"
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
/etc/init.d/mysqld start

echo  "-----init  password of MySQL-----"
OLD_PWD=`cat /server/mysql_data/error.log | grep password |awk -F: '{print $5}' |awk '{print $1}'`
echo 'old password:$OLD_PWD'
NEW_PWD=`openssl rand -base64 9`
echo 'set password for 'root'@'localhost' =password('$NEW_PWD');'





 

你可能感兴趣的:(MySQL)