Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mysqldump error

Status
Not open for further replies.

kzn

MIS
Jan 28, 2005
209
0
0
GB
I am trying to set up a backup routine using windows task scheduler but the problem I am having starts before I even use task scheduler.

C:\Program Files\MySQL\MySQL Server 5.5\bin>mysqldump -h localhost -u root -pMypass mydatabase > c:\10am.txt
mysqldump: Got error: 1045: Access denied for user 'ODBC'@'localhost' (using password: YES) when trying to connect

if I enter the following
C:\Program Files\MySQL\MySQL Server 5.5\bin>mysqldump -h localhost -u root -p mydatabase > c:\10am.txt
and then enter the password it works, but I dont want to have to keep putting in the password manually because I want this to be automated by task scheduler.I dont understand why it would be complaining.

 
does it work with --password=PASSWORD ?

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Hi Chris

No it does not ... I get the same error. Very strange, my plan was to use task scheduler. I have been looking at the MYSQL Administrator console and there is an option for running backups there. I have created a backup user with grant all rights, but watching a youtube video the person mentions you must use the root user? surely the account I have created should be ok?

With regards to the problem, I can not for the life of my understand why it does not work. By the way, I have it installed on server 2012 running mysql 5.5.

Thanks,
 
you can use whatever user has appropriate privileges.

C:\Program Files\MySQL\MySQL Server 5.5\bin>mysqldump -h localhost -u root -pMypass mydatabase > c:\10am.txt
mysqldump: Got error: 1045: Access denied for user 'ODBC'@'localhost' (using password: YES) when trying to connect

I find that very odd as you are not specifying the ODBC user in the connection string.

try using the long/explicit form

Code:
mysqldump --host=localhost --user=root --password=myPassword --opt mydatabasename > c:\10am.txt

also be sure that you have properly created the user.

if you are using root, then remember that the root account is locked to the localhost only unless you have explicitly told mysql otherwise.

to create a backup user you might try the following

Code:
mysql --user=root --password=rootpassword --host=localhost
mysql> GRANT LOCK TABLES, SELECT ON *.* TO 'myBackupUser'@'%' IDENTIFIED BY 'myBackupUserPassword';
mysql> flush privileges;
 
Aah, the wonders of YouTube where everyone is an "expert".

However the user having SELECT privileges on ALL databases and tables should be sufficient,
SQL:
USE mysql;
GRANT SELECT ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password';

but your script/command line is not even getting that far, so it is possibly the allowed hosts for the user that is tripping it up.

Check what hosts are allowed with:
SQL:
USE mysql;
select User,Host from mysql.user;





Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Thank you both for the replies, I have achieved what I needed using the MySQL Administrator backup facility. I have set up hourly backups to run daily. Strangely trying both your methods did not work. By the way I am running this directly on the Mysql server with the root username and password and still get the same issue and as mentioned before if I run the command without the password and when it prompts me it works. That is just to prove it works but not what I want. My thinking is there must be something wrong with MySQL?

Thanks again.
 
occam's razor suggests that it's more likely to be something wrong with the way you are entering the commands or the way that your system is set up; or the way that you have granted perms to the users.

if mysql were unstable only in this one way I'd be very surprised indeed!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top