Mysql – Remote MySQL Dump not working with cnf file

MySQL

I have created a user 'backup'@'%' with Grant all privileges access to .

I have added the user backup to my.cnf file

When I do the following in CMD:

mysqldump -p3306 -h<dns/ip> db-name table-name > D:\table-name.sql

I get an error 1045: Access denied for the user 'backup'@'' using password: YES when trying to connect

However, when I do the below with user and password credentials it work

mysqldump -p3306 -h<dns/ip> --user=backup --password=<secret> db-name table-name > D:\table-name.sql

I cant get my head around this can someone please help

Best Answer

You need to supply username used to login while logging try this

mysqldump -u backup -P3306 --user=backup -p db-name table-name > D:\table-name.sql

You need to note that from mysql documentation

-P port (capital P)

-ppassword (no cap, no space) also equal to --password=password; -p without anything immediately after it prompts for the password.