Solution to error 1045 in mysqldump

Error message:
mysqldump: Got error: 1045: Access denied for user ‘root’@’localhost’ (using pas
sword: YES) when trying to connect
Operating environment: CMD
You can log into mysql normally with [email protected], but mySQldump denied access, checked the root permission, found that there was no problem with the permission, and finally decided to create a new experiment account

CREATE USER [email protected]'localhost' IDENTIFIED BY 'dumper';
GRANT select ON test.* TO [email protected];
GRANT show view ON test.* TO [email protected];
GRANT trigger ON test.* TO [email protected];
GRANT lock tables ON test.* TO [email protected];

Dumper is set to back up the Test library, can log in to the database normally, and still cannot access mySQldump
I began to add parameters to mySQldump gradually, and finally found that the access was successful after adding port -P3307

mysqldump -udumper -pdumper -hlocalhost -P3307 test>test.sql

According to the configuration file, the port of mysql has been modified to 3307, but mySQldump defaults to 3306. After that, the root account can also be normally backed up

Read More: