一、报错信息
在使用mysqldump
执行远程备份数据库的时候报如下错误:
mysqldump: Got error: 1044: Access denied for user XXXX when doing LOCK TABLES
很明显此问题,是由于用户没有权限。可以登录mysql
服务查询用户的权限。
SHOW GRANTS [FOR user]
二、报错原因
查看下mysql
官方手册有如下描述:
mysqldump requires at least the SELECT privilege for dumped tables, SHOW VIEW for dumped views, TRIGGER for dumped triggers, LOCK TABLES if the --single-transaction option is not used, and (as of MySQL 5.7.31) PROCESS if the --no-tablespaces option is not used. Certain options might require other privileges as noted in the option descriptions.
三、解决方式
1、分配权限
可以使用 GRANT
命令分配 LOCK TABLES
权限,如下所示:
GRANT LOCK TABLES ON `db_name`.* TO 'user'@'%';
2、跳过锁表
在 mysqldump
命令时添加 --skip-lock-tables
跳过锁表。如下所示:
mysqldump -h host_name -uuser -ppassword --databases db_name --tables table_name> F:\dump.sql
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)