When executing the script, you need to keep up with the database name you need to back up, as follows
#!/bin/bash
#auto backup MySQL
#20180522 by Jzh
#################################
#Define PATH definition Variable
back_dir=/data/backup/mysql/' Date +%y-%m-%d '
Mysqldb=$1
Mysqlpw=backup
Mysqlusr=backup
#You must use root user run scripts must be run with root, $UID as system variable
if [[-Z $]];then
echo "Usage:{sh $ DB_NAME,EXAMPLE:SH $ discuz|mysql}"
Exit
Fi
if [[$UID-ne 0]];then
echo "This script must use the root user!"
Sleep 5
Exit
Fi
#Define dir and mkdir dir to determine if the directory exists and does not exist the new
if [[!-D Back_dir]];then
Mkdir-p $BACK _dir
Fi
#Use mysqldump backup MySQL uses mysqldump to back up the database
if [[$1-ne "All"]];then
/usr/bin/mysqldump-u$mysqlusr-p$mysqlpw-d $MYSQLDB > $BACK _dir/{$1}_db.sql
Else
/USR/BIN/MYSQLDUMP-U$MYSQLUSR-P$MYSQLPW--all-databases > $BACK _dir/{$1}_db.sql
Fi
if [[$?-eq 0]];then
echo "The MySQL backup successfully in $BACK _dir"
Else
echo "The MySQL backup failed"
Fi
Using the shell for MySQL backup