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

版权声明:如若转载,请联系作者。 https://blog.csdn.net/liu16659/article/details/84838764

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.

猜你喜欢

转载自blog.csdn.net/liu16659/article/details/84838764
今日推荐