Home >Database >Mysql Tutorial >mysqldump使用脚本自动备份mysql数据库

mysqldump使用脚本自动备份mysql数据库

WBOY
WBOYOriginal
2016-06-06 09:34:401166browse

脚本mysql备份

在linux服务器使用脚本自动数据库时,报如下错误,备份不成功,求问大神如何解决:
Warning: Using a password on the command line interface can be insecure

以下是我的脚本:
#!/bin/sh
DUMP=/usr/local/mysql/bin/mysqldump
OUT_DIR=/home/dbbak/today
OUT_HISTORY_DIR=/home/dbbak/oldday
DB_NAME=yjs
DB_USER=root
DB_PASS=root
DATE=date +%Y%m%d-%H%M%S
echo $DATE
cd $OUT_DIR
OUT_SQL="$DATE.sql"
$DUMP -u$DB_USER -p$DB_PASS $DB_NAME --default-character-set=utf8 --opt -Q -R --skip-lock-tables > $OUT_SQL
find $OUT_DIR -name "*.sql" -type f -mtime +0 -exec mv {} $OUT_HISTORY_DIR \;
find $OUT_HISTORY_DIR -name "*.sql" -type f -mtime +3 -exec rm {} \;

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn