mysqldump Error 1045 Access denied despite correct passwords etc

后端 未结 28 1165
执笔经年
执笔经年 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:16

    Put The GRANT privileges:

    GRANT ALL PRIVILEGES ON mydb.* TO 'username'@'%' IDENTIFIED BY 'password';
    
    0 讨论(0)
  • 2021-01-30 13:16

    I had the same error. Only occurred after moving from my normal work PC to a PC at a different location.

    I had to add my public IP ho address to Remote MySQL in my CPanel at my host site

    0 讨论(0)
  • 2021-01-30 13:18

    For MAMP PRO users (or anyone who's mysql is in a weird location) be prepared to specify the mysql full path from the boonies and also specify full path to your user local folder where you want to dump the file or you'll get the "permission denied error"..

    Following worked for me after 3 hours of research:

    /Applications/MAMP/Library/bin/mysqldump  -u root -proot YOUR_DB > /Users/YOUR_USER/yourdump2.sql
    
    0 讨论(0)
  • 2021-01-30 13:21

    Don't enter the password with command. Just enter,

    mysqldump -u <username> -p <db_name> > <backup_file>.sql
    

    Then you will get a prompt to enter password.

    0 讨论(0)
  • 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
    0 讨论(0)
  • 2021-01-30 13:22

    Doing without the -u and -p worked for me (when I was logged in as root):

    mysqldump --opt mydbname > mydbname.sql
    
    0 讨论(0)
提交回复
热议问题