mysqldump: Got error: 1044: Access denied for user ‘xxx’@’localhost’ when using LOCK TABLES

【linux命令】mysqldump: Got error: 1044: Access denied for user ‘xxx’@’localhost’ when using LOCK TABLES

初次开始写mysql备份脚本的朋友,相信你们都遇到该报错:
mysqldump: Got error: 1044: Access denied for user ‘xxx’@’localhost‘ to database ‘xxx’ when using LOCK TABLES
解决办法:数据库名后边添加–skip-lock-tables 

mysqldump -uxxx -p123456   –skip-lock-tables –opt $i | gzip > /home/backup/$dateDIR/data/${i}_${dateDIR}.sql.gz

分析:
mysqldump: Got error: 1044: Access denied for user ‘xxx’@’localhost’ to xxx’information_schema’ when using LOCK TABLES

那可能是你用来备份的数据库用户没有lock table的权限,可以换一个权限更高的用户,比如使用root(安全角度最好不要用这个用户,避免非服务器超管人员获取root密码),或者使用mysqldump的另一个选项:–single-transaction

mysqldump -uxxx -p123456  –default-character-set=utf8 –single-transaction –opt $i | gzip > /backup/$dateDIR/data/${i}_${dateDIR}.sql.gz

hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 » mysqldump: Got error: 1044: Access denied for user ‘xxx’@’localhost’ when using LOCK TABLES