Problem In Database Backup

Posted on 2002-07-25
Medium Priority
Last Modified: 2011-10-03

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.

Question by:Zuhair070699
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
LVL 40

Expert Comment

by:Richard Quadling
ID: 7177005
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.
LVL 40

Expert Comment

by:Richard Quadling
ID: 7177028
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 ...


$fp = fopen("sql.log","r+");


Sort of thing.



LVL 40

Expert Comment

by:Richard Quadling
ID: 7177036
To get the value for the position of the lines in the file ...


$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.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 7177216

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

LVL 40

Accepted Solution

Richard Quadling earned 800 total points
ID: 7177226
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.

Author Comment

ID: 7177299
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 :)
LVL 40

Expert Comment

by:Richard Quadling
ID: 7177328
Excellent and thank you.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

649 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