MySQL报错mysqldump: Got error: 1044: Access denied for user... when doing LOCK TABLES

MySQL报错mysqldump: Got error: 1044: Access denied for user... when doing LOCK TABLES

1. 报错如下

mysqldump: Got error: 1044: Access denied for user 'u_lawson'@'%' to database 'datamart' when doing LOCK TABLES

2. 报错原因

mysqldump requires at least the SELECT privilege for dumped tables, SHOW VIEW for dumped views,
TRIGGER for dumped triggers, and LOCK TABLES if the --single-transaction option is not used.
Certain options might require other privileges as noted in the option descriptions.

mysqldump 命令执行时,需要四种权限,分别是:select,show view,trigger,lock table。但是因为没有lock table的权限,导致上述错误发生。

3. 解决办法

在mysqldump命令之后添加--single-transaction 即可。

4. 示例如下

D:\Program Files\MySQL\MySQL Server 5.7\data>mysqldump -hxx.xx.xxx.xxx -uu_lawson -p123456 datamart dim_sub_channel_type > dim_sub_channel_type.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: Got error: 1044: Access denied for user 'u_lawson'@'%' to database 'datamart' when doing LOCK TABLES

D:\Program Files\MySQL\MySQL Server 5.7\data>mysqldump --single-transaction -hxx.xx.xxx.xxx -uu_lawson -p123456 datamart dim_sub_channel_type > dim_sub_channel_type.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.

你可能感兴趣的:(Mysql)