mysqldump Error 1045 Access denied despite correct passwords etc

后端 未结 28 1568
执笔经年
执笔经年 2021-01-30 12:56

This is a tricky one, I have the following output:

mysqldump: Got error: 1045: Access denied for user \'root\'@\'localhost\' (using password: YES) when tr

28条回答
  •  半阙折子戏
    2021-01-30 13:21

    I had the problem that there were views that had a bad "DEFINER", which is the user that defined the view. The DEFINER used in the view had been removed some time ago as being "root from some random workstation".

    Check whether there might be a problem by running:

    USE information_schema; 
    SELECT DEFINER, SECURITY_TYPE FROM views;
    

    I modified the DEFINER (actually, set the DEFINER to root@localhost and the SQL SECURITY value to INVOKER so the view is executed with the permissions of the invoking user instead of the defining user, which actually makes more sense) using ALTER VIEW.

    This is tricky as you have to construct the appropriate ALTER VIEW statement from information_schema.views, so check:

    • Modify DEFINER on many views
    • MySQL error 1449: The user specified as a definer does not exist

提交回复
热议问题