本地安装mysql脚本

[root@tianyun ~]# vim mysql_install.sh

#!/usr/bin/env bash

#mysql install 2

#by tianyun

#yum 配置yum源

$ip  rm –rf /etc/yum.repos.d/*

wget ftp://172.16.8.100/yumrepo/centos7.repo -P /etc/yum.repos.d/

wget ftp://172.16.8.100/yumrepo/mysql57.repo -P /etc/yum.repos.d/

yum –y install lftp vim-enhanced bash-completion

#scp –r centos7.repo root@$ip:/etc/yum.repos.d/

#关闭防火墙和selinux

#Firewalld & SElinux

systemctl stop firewalld

systemctl disable firewalld

setenforce 0

sed –ri ‘/^SELINUX/c\SELINUX=disabled’ /etc/selinux/config

#设置时钟

#ntp

yum –y install chrony

sed –ri ‘/3.centos/a\server 172.16.8.100 iburst’  /etc/chrony.conf

#启动时钟服务

systemctl start chronyd

systemctl enable chronyd

#install mysql5.7

yum –y install mysql-community-server

#启动mysql

systemctl start mysqld

systemctl enable mysqld

grep ‘temporary password’ /var/log/mysqld.log | awk ‘{print $NF}’ > /root/mysqloldpass.txt

#改mysql的初始密码

mysqladmin –uroot –p’`cat /root/mysqloldpass.txt`’ password ‘(TianYunYang123)

posted @ 2019-01-27 18:04  莫孟林  阅读(374)  评论(0编辑  收藏  举报