Hi people!
Just recently got into coding and i'm a total idiot in it. I got no idea how to backup data in the database.
Anyone have any PHP script which i can use to backup data in the database?
After backing up, how do i restore using PHP codes?
How to backup data in the database?
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: How to backup data in the database?
There are a million tutorials that can do this.
Basically it comes down to running the following query, which basically just dumps the contents of the table into a file.
SELECT * INTO OUTFILE 'your_backup_file.sql' FROM `your_table_name`
Creating a PHP script to run this, then configure a cron job to run the PHP script at whatever interval.
Then to load it
LOAD DATA INFILE 'your_backup_file.sql' INTO TABLE `your_table_name`
And finally, for my favorite resource which will answer your question in extreme detail - http://lmgtfy.com/?q=PHP+MySQL+backup
Basically it comes down to running the following query, which basically just dumps the contents of the table into a file.
SELECT * INTO OUTFILE 'your_backup_file.sql' FROM `your_table_name`
Creating a PHP script to run this, then configure a cron job to run the PHP script at whatever interval.
Then to load it
LOAD DATA INFILE 'your_backup_file.sql' INTO TABLE `your_table_name`
And finally, for my favorite resource which will answer your question in extreme detail - http://lmgtfy.com/?q=PHP+MySQL+backup