#!/bin/bash bak_file_name=`date +%f` bak_dir='/mysqlbak' user='root' pwd='123456' dbname='' [ -e $bakdir ] || mkdir $bakdir mysqldump -u$user -p$pwd --flush-logs $dbname > $bakdir/bak_file_name-$dbname.sql