1. 程式人生 > >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

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.