Forum Statistics

  • Forum Members: 4,246
  • Total Threads: 3,572
  • Total Posts: 10
There are 1 users currently browsing forums.

Partner Sites

Reply
Old 10-25-2008, 01:07 AM   #1 (permalink)
 
Status: Account Temporarily Suspended
Join Date: Jun 2008
Location: My Computer Room
Posts: 158

Rep Power: 0 vampire is on a distinguished road



Lightbulb 3 Simple Ways to Backup your MySQL Database

Okay, I gone through many problems this past few months and one thing i learned is always keep a backup of all your data from the server. The most important thing which should not be manipulated by anything is your database.

Most of them would be knowing this but for those who are unaware please read along to stay safe.

There are many ways to get backup of your database , I will show you 3 simplest possible ways.

Execute a database backup query from PHP file.
By using SELECT INTO OUTFILE query for creating table backup
Code:
<?php
include 'config.php';
include 'opendb.php';

$tableName  = 'mypet';
$backupFile = 'backup/mypet.sql';
$query      = "SELECT * INTO OUTFILE '$backupFile' FROM $tableName";
$result = mysql_query($query);

include 'closedb.php';
?>
For Restoring the backup you just need to run LOAD DATA INFILE query
Code:
<?php
include 'config.php';
include 'opendb.php';

$tableName  = 'mypet';
$backupFile = 'mypet.sql';
$query      = "LOAD DATA INFILE 'backupFile' INTO TABLE $tableName";
$result = mysql_query($query);

include 'closedb.php';
?>
Run mysqldump using system() function
The system() function is used to execute an external program. Because MySQL already have built in tool for creating MySQL database backup (mysqldump) use it from own PHP script like :
Code:
<?php
include 'config.php';
include 'opendb.php';

$backupFile = $dbname . date("Y-m-d-H-i-s") . '.gz';
$command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile";
system($command);
include 'closedb.php';
?>
Use phpMyAdmin to do the backup
The most easiest and convenient way to get your database backup.
To backup your MySQL database using phpMyAdmin click on the "export" link on phpMyAdmin main page. Choose the database you wish to backup, check the appropriate SQL options and enter the name for the backup file.


If you still get any problems with your server or Database contact any of the Staff members of FG , we would definitely help you out.
The Admins are really helpful , I remember when i was stuck in some problem the Admins helped me out with the utmost ease .
vampire is offline Add Infraction for vampire   Reply With Quote
Old 10-25-2008, 07:10 AM   #2 (permalink)
Sarahlee
 
Status: Guest
Posts: n/a



Default

Great work Vampire. That is a big help as I see this is the worst issue you see nowadays. Thank you for writing that up and posting.
  Edit/Delete Message Reply With Quote
Old 11-05-2008, 10:43 PM   #3 (permalink)
 
Status: FG Regular
Join Date: Sep 2008
Posts: 50

Rep Power: 19 cool sam is on a distinguished road



Default

There are numerous ways to backup and restore your MySQL database, from the simple to the complex, both manual and automatic, some reliable and others spotty. In this post, I’ll outline several strategies for keeping your MySQL database safe and secure. Since I use WordPress, I’ll talk specifically about backing up a WordPress database, but one of these strategies is sure to work for you regardless of which blogging software you use.



__________________________________________
Web Design | Web Designing India
cool sam is offline Add Infraction for cool sam   Reply With Quote
Old 11-15-2008, 09:54 AM   #4 (permalink)
 
Status: Newbie
Join Date: Nov 2008
Posts: 3

Rep Power: 14 linkbuilding-services is on a distinguished road



Default

Thank you for this tips. I use phpmyadmin, but when that's not installed on the system we can use your tips.
linkbuilding-services is offline Add Infraction for linkbuilding-services   Reply With Quote
Old 11-17-2008, 07:46 AM   #5 (permalink)
 
sourcefreelance's Avatar
 
Status: Super Mod Staff
Join Date: Oct 2008
Location: Irl
Posts: 76

Rep Power: 21 sourcefreelance is on a distinguished road

Send a message via ICQ to sourcefreelance


Default

Vampire you've helped so many people in your travels.. And i often wonder, are you really a human!

Nevertheless! PHPmyAdmin... A GODSEND! I recommend it to anyone looking out for hosting plans!
__________________
Dont Spam.. We're Tired of it.
sourcefreelance is offline   Reply With Quote
Old 11-17-2008, 08:10 AM   #6 (permalink)
 
Status: member
Join Date: Oct 2008
Posts: 19

Rep Power: 15 DisneyTech is on a distinguished road



Default

This deserves a sticky, as the backup of a database is very important, and you have outlined the steps clearly.

~DisneyTech
Administrator
DisneyTech is offline Add Infraction for DisneyTech   Reply With Quote
Old 07-24-2011, 09:07 AM   #7 (permalink)
diannamori
 
Status: Guest
Posts: n/a



Default

thanks for the usefull post
  Edit/Delete Message Reply With Quote
Old 08-03-2011, 04:06 PM   #8 (permalink)
Tonkist
 
Status: Guest
Posts: n/a



Default Танкистка оче

уважаемая администрация сайта! прошу удалить это сообщение!! я нечаяно :(
  Edit/Delete Message Reply With Quote
Old 08-04-2011, 04:05 PM   #9 (permalink)
Unregistered
 
Status: Guest
Posts: n/a



Default Танкистка оче

уважаемая администрация сайта! прошу удалить это сообщение!! я нечаяно :(
  Edit/Delete Message Reply With Quote
Old 08-16-2011, 03:45 AM   #10 (permalink)
Optighdig
 
Status: Guest
Posts: n/a



Default Pantofi

Hello guys & gals, I’m Joe!
  Edit/Delete Message Reply With Quote


Reply

Bookmarks

Tags
backup, database, mysql, php, phpbmyadmin


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may post new threads
You may post replies
You may post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.5.0 RC2