Solved

Problem In Database Backup

Posted on 2002-07-25
7
187 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
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 

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 200 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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
This article discusses how to implement server side field validation and display customized error messages to the client.
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.

726 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