自动备份数据库脚本

    xiaoxiao2021-03-25  150

    自动备份数据库

    #!/bin/bash read -p "Please enter username:" USER read -p "Passwd:" -s PASSWD mysql -u$USER -p$PASSWD -e "SHOW DATABASES;" &>/dev/null if [ "$?" != "0" ] then echo -e "\nwhat you written is wrong" exit else mysql -u$USER -p$PASSWD -e "SHOWDATABASES;" #用user用户登录,密码是passwd read -p "Please enter the file what you want to copy:" DBNAME read -p "Please give a path(/XXX/XXX.sql):" DCH mysqldump -u$USER -p$PASSWD $DBNAME > $DCH fi if [ "$?" = "0" ] then echo "finished" else echo "fail" fi
    转载请注明原文地址: https://ju.6miu.com/read-24787.html

    最新回复(0)