Over a million developers have joined DZone.

Export And Import By Php

There are at least three ways to backup your MySQL Database :

Execute a database backup query from PHP file.
Run mysqldump using system() function.
Use phpMyAdmin to do the backup.

Execute a database backup query from PHP file

Below is an example of using SELECT INTO OUTFILE query for creating table backup :

To restore the backup you just need to run LOAD DATA INFILE query like this :

It's a good idea to name the backup file as tablename.sql so you'll know from which table the backup file is

Run mysqldump using system() function

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}