?
Solved

Problem In Database Backup

Posted on 2002-07-25
7
Medium Priority
?
188 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
[X]
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
7 Comments
 
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.
0
 
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 ...

<?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:Richard Quadling
ID: 7177036
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
7 Extremely Useful Linux Commands for Beginners

Just getting started with Linux? Here's a quick start guide that has 7 commands that we believe will come in handy.

 

Author Comment

by:Zuhair070699
ID: 7177216
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:
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.
0
 

Author Comment

by:Zuhair070699
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 :)
0
 
LVL 40

Expert Comment

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

Featured Post

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

770 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