在执行备份脚本时出错

时间:2016-06-20 08:22:07

标签: mysql

我有一个查询,我无法理解这里的确切问题。

我创建了这个备份脚本:

#!/bin/bash

USER="root"
PASSWORD="password123"
OUTPUT="/mysql/backup/"

rm "$OUTPUT/*gz" > /dev/null 2>&1

databases=`mysql --user=$USER --password=$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`

for db in $databases; do
    if [[ "$db" != "information_schema" ]] && [[ "$db" != _* ]] ; then
        echo "Dumping database: $db"
        mysqldump --force --opt --user=$USER --password=$PASSWORD  --databases $db > $OUTPUT/`date +%Y%m%d`.$db.sql
        gzip $OUTPUT/`date +%Y%m%d`.$db.sql
fi
done
#
find $OUTPUT -mtime +3 |xargs rm -fv

当我执行脚本时,我得到以下错误:

[root ~]# sh /mysql/mylog/script/dbbackup.sh 
Dumping database: dbbackup
Dumping database: ilias
mysqldump: Got error: 1016: Can't open file: './ilias/payment_coupons_track.frm' (errno: 24) when using LOCK TABLES
Dumping database: jira
Dumping database: mysql
-- Warning: Skipping the data of table mysql.event. Specify the --events option explicitly.
Dumping database: personal-care
VDumping database: performance_schema
mysqldump: Got error: 1142: SELECT,LOCK TABL command denied to user 'root'@'localhost' for table 'cond_instances' when using LOCK TABLES
Dumping database: test
===================================================================

以下是root用户的权限。

mysql> show grants for 'root'@'localhost';

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*F60EF8B0ABADBD0B34E77CF7EC8ADFA01FBE327F' WITH GRANT OPTION

GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION

请让我知道我在这里错过了什么。

非常感谢你 普什帕

0 个答案:

没有答案