#!/bin/bash
if [ $(id -u) != "0" ]; then
echo "Error: 必须以root权限运行此脚本"
exit 1
fi
echo "~~~~ 停止正在运行的容器 ~~~~"
docker stop mysql5.6
sleep 1
echo "~~~~ 删除已存在的容器 ~~~~"
docker rm mysql5.6
sleep 1
if [ ! -d "/usr/local/data/mysql" ]; then
echo "~~~~ 新建数据目录 ~~~~"
mkdir /usr/local/data/mysql
chmod -R 777 /usr/local/data/mysql
fi
if [ ! -d "/usr/local/conf/mysql" ]; then
echo "~~~~ 新建配置文件目录 ~~~~"
mkdir /usr/local/conf/mysql
chmod -R 777 /usr/local/conf/mysql
fi
if [ ! -f "/usr/local/conf/mysql/5.6/my.cnf" ]; then
echo "~~~~ 新建配置文件 ~~~~"
touch /usr/local/conf/mysql/5.6/my.cnf
fi
echo "~~~~ 部署mysql5.6 ~~~~"
docker run -d -p 33056:3306 -e MYSQL_ROOT_PASSWORD=root -v /usr/local/data/mysql/5.6:/var/lib/mysql -v /usr/local/conf/mysql/5.6/my.cnf:/etc/my.cnf --privileged --name=mysql5.6 mysql:5.6
echo "~~~~ 部署完成 ~~~~"
sleep 1
docker ps | grep mysql5.6
sleep 1
docker ps | grep mysql5.6
sleep 1
docker ps | grep mysql5.6
sleep 1
docker ps | grep mysql5.6
sleep 1
docker ps | grep mysql5.6