简体   繁体   中英

Win 10, MySQLDump gives error “mysqldump: Got error: 1045: Access denied for user '=root'@'localhost' (using password: YES) when trying to connect”

I tried the other solutions that had been mentioned in other answers, such as permissions, grant issues, port number, password/user name, etc. These were all not the problem; they could be your problem so do need to be checked.

Configuration: Running Wordpress on Win10, MariaDB installed, up to date at the time.

Using the exact syntax below, I get an access denied error. Password IS correct. Root user does have full database admin rights

[D:\DiskBackups]mysqldump -u=root -p mysql
Enter password: *********
mysqldump: Got error: 1045: Access denied for user '=root'@'localhost' (using password: YES) when trying to connect

Apparently, if MySQL cant' resolve the name properly (not sure why) it throws 'Access Denied'. Security through obscurity.

Answer in my case was to specify the localhost via IP address:

mysqldump -u root -p  -h 127.0.0.1 mysql > JG_MultiSite2018_0122.bak

Despite the fact that MySQLDump seems to recognize the command through 'localhost' you have to actually give the 127.0.0.1 IP address for it to work. It all worked fine then!

Note that by giving "-p" without an actual password avoids any issues of quotes, spaces, special characters, etc. You can, of course, specify an actual password on the command line, BUT you will still get the error without the -h 127.0.0.1

I couldn't add this as a solution to other similar questions; most answers discussed permissions, grants, etc.

Try specifying the port. I'm on Windows 10 MySQL 8.0. Without a port argument I got the same error:

C:\Users\user>mysqldump -u root -p airlines_test > C:\...\test\airlines_test_dump.sql
Enter password: ******************
mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect

I fixed this by specifying the port to use: -P 3306 :

C:\Users\user>mysqldump -u root -p -P 3306 airlines_test > C:\...\test\airlines_test_dump.sql
Enter password: ******************

C:\Users\user>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM