ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] ## 自动备份Mysql数据库 ``` #!/bin/bash #使用方法,位置参数1为需要备份的数据库名,如果固定备份则直接修改参数MysqlDB Backdir=/data/backup/mysql/`date +%Y-%m-%d` MysqlDB=$1 MysqlUser=root MysqlPD=www.upsoft01.com if [ $UID != "0" ]; then echo "This script must use root user ,please exit!" exit 0 fi if [ -e $1 ]; then echo "must input database" exit 0 fi [ ! -e ${Backdir} ] && mkdir -p ${Backdir} Mysql_Backup () { /usr/bin/mysqldump -u${MysqlUser} -p${MysqlPD} ${MysqlDB} | gzip > ${Backdir}/${MysqlDB}-`date +%Y-%m-%d`.sql.gz } Mysql_Backup ``` ## Mysql复杂操作脚本实例 ``` mysql -uroot -pwww.upsoft01.com antdbms_aipu -e 'show tables' | awk '{print $1}' ```