Problem In Database Backup

Hi,

Actually I have complicated problem with database backup, and I can summarize it as following:

I have website with disk quota of 500MB and I have a bulletin board that takes about 450MB (database size).

Now I can't upgrade my site disk quota over 500MB because it is the highest plan on the hosting company.

Ok, the host company solves the problem when they take a backup to me and put it some where.

Now, I gzip the database backup and transfer it to my new site which disk quota is 2.5 GB , I create a new database and user and I use telnet to restore the backup:
__________________________________________________
mysql new_database_name -unew_user_name -pxxxxx < my_backup.sql
__________________________________________________

But I got an error:

"ERROR 1044 at line 11: Access denied for user: 'new_user_name@localhost' to database 'old_database_name'"

I use the same mysql command with other small backup and it is work fine !

I open the beginning of my backup file and I notice that in line number 11:

==================
CREATE DATABASE /*!32312 IF NOT EXISTS*/ old_database_name;

USE old_database_name;
==================

And I think this is the problem.

I ask the support man in my old website hosting company about that and he said that:

"Decompress the backup file, then you should be able to delete the lines in it. However, you should just need to delete the first line, not the second."

And my response was:

"It is not logical to download backup file with more than 400MB and delete one line then save it and upload it again !

What is the editor that can open this huge file?

How can I download and then upload this huge file while I am using dialup connection ?

Is there other solution?

Please, I need your help"

I am still waiting the technical support response for more than 2 hours, and I hope to get a solution for my problem from you ASAP.

Thanks,
Zuhair070699Asked:
Who is Participating?
 
Richard QuadlingConnect With a Mentor Senior Software DeveloperCommented:
No it won't. The process open the file and amends a part of the file and then closes it.

If does not create a copy or anything like that.

But you have to know the EXACT address to drop into and the exact thing you want to overwrite with.

To delete a line using this method, you would simply fill the line with spaces.

If you want to replace a line with a line that has less on it, you must pad the line out with spaces.
0
 
Richard QuadlingSenior Software DeveloperCommented:
If you have ICQ I am on 1711757. I'll do it for you if you can tell me where I can FTP the file from.
0
 
Richard QuadlingSenior Software DeveloperCommented:
If you know the EXACT line you want to replace, you could open the file in read/write mode, position yourself to the beginning of the line you want to write and then write out the EXACT number of bytes that the line contains, changing the line.

On a DOS system, the lines would have CR/LF at the end of them. On a unix system, I think only 1 of them.

This would look something like ...

<?php

$fp = fopen("sql.log","r+");
fseek($fp,some_number,SEEK_SET);
fwrite($fp,"THE EXACT SAME LINE LENGTH AS BEFORE");
fclose($fp);

?>

Sort of thing.

BUT IF YOU GOT ANYTHING WRONG, YOU WILL PROBABLY CORRUPT THE FILE!!!!

Regards,

Richard.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Richard QuadlingSenior Software DeveloperCommented:
To get the value for the position of the lines in the file ...

<?php

$fp = fopen("sql.log","r");
while !feof($fp)
{
echo ftell($fp) . ' - ' . fgets($fp,4096);
}

?>

4096 for a long line. If you get partial lines, then increase this number.
0
 
Zuhair070699Author Commented:
Hi,

Is this solution cause an issue with memory usage of the server, if you notice that the backup file is more than 400MB?

Thanks,
0
 
Zuhair070699Author Commented:
Thanks for your help :)

I try it and its works fine on second script that you post you have minor mistak at line 4 :

while !feof($fp)

should be (!feof($fp))

I am know restorung my backup thanks again :)
0
 
Richard QuadlingSenior Software DeveloperCommented:
Excellent and thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.