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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 1045 with "BACKUP TABLE tbl_name TO '/path/to/backup/directory'"

Status
Not open for further replies.

MrDubDub

Programmer
Feb 27, 2003
3
RO
I have developed a PHP/MySQL driven website, and I want the site administrator to be able to back the db up when they want. It's all running on a hosting service.

The solution I came up with was when the administrator requests a backup:
1) create a new directory with name=timestamp
2) for each table, use a mysql "BACKUP TABLE" statement to export the table into the new directory.

Step 1 works fine, but step 2 fails with error 1045, Access denied for user: 'user_name@localhost' (Using password: YES).

Extra info:
- I've not GRANTed anything in the database
- INSERT/UPDATE/DELETE/SELECT works fine
- the newly created directory is chmod'ed to 0777

Anyone used this backup method before? (and got it to work!).

One more question ... is the path in the BACKUP statement absolute or relative? (and if relative, relative to what - the php script location?)

tia

 
Problem solved! Turns out to be a wierd php problem, not MySQL at all.

If you're interested, the solution was to not connect to the db using a function, but to connect (mysql_pconnect/mysql_select_db) in the actual script.

Same code, just doesn't work if it's executed in a function. Wierd or what?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top