Couldn‘t execute ‘SHOW MASTER STATUS‘: Access denied; you need (at least one of) the SUPER, REPLICAT

mysqldump 备份,遇到权限不足问题:(一下脚本需要备份的账户至少拥有以下权限 select, reload, lock tables, REPLICATION client)

#!/bin/bash

user='数据库用户名'
password='数据库密码'
dbname='数据库名'
date=`date +%Y%m%d`
year=`date +%Y`
month=`date +%m`
day=`date +%d`

# 创建备份文件目录和备份文件名
backup_dir=/archive/data/$year/$month/$day
filename=$dbname-${date}.sql.gz

# mkdir directory recursely
if [ ! -d $backup_dir ]; then
	mkdir -p $backup_dir
fi

# single-transaction quick master-data 三个参数的含义详见文底摘录的官方描述 --
/www/server/mysql/bin/mysqldump --single-transaction --quick --master-data = 2 -u"$user" -p"$password" "$dbname" | gzip > ${backup_dir}/$filename

给备份账户赋予以上权限:

grant select, reload, lock tables on *.* to `数据库用户名`@'localhost' with grant option;

GRANT REPLICATION client ON *.* TO '数据库用户名'@'localhost';

不知道为什么以上两条语句放在一条执行的时候,提示语法错误:

-- grant select, reload, lock tables, REPLICATION client, on *.* to `数据库用户名`@'localhost' with grant option; -- 这个执行提示语法错误

参考:
https://www.tutorialspoint.com/how-to-grant-replication-privilege-to-a-database-in-mysql

上一篇:apex使用


下一篇:【DB笔试面试96】在MySQL中,下列SQL语句中,可为用户ZHANGSAN分配数据库USERDB表USERINFO的查询()