Solved

Problem In Database Backup

Posted on 2002-07-25
7
183 Views
Last Modified: 2011-10-03
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,
0
Comment
Question by:Zuhair070699
  • 5
  • 2
7 Comments
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
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
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
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
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:Zuhair070699
Comment Utility
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
 
LVL 40

Accepted Solution

by:
RQuadling earned 200 total points
Comment Utility
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
 

Author Comment

by:Zuhair070699
Comment Utility
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
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
Excellent and thank you.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now