SQL select command will do backup operation. Table wise we can take back up for taking backup of each table we need to execute select query each time and store the details into a text file.
using the select into query we can execute the back up operation of a table
Example
——-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<?php $databasehost = 'localhost'; $databaseuser = 'root'; $databasepassword = ''; $connection = mysql_connect($databasehost, $databaseuser, $databasepasswoed); if(! $connection ) { die('Could not connect: ' . mysql_error()); } $table_name = "mydoubts_table"; $backup_file = "/tmp/mydoubts.sql"; $sqlqry = "SELECT * INTO OUTFILE '$backup_file' FROM $table_name"; mysql_select_db('mydoubts_db'); $output = mysql_query( $sqlqry, $connection); if(! $output) { die('Could not take data backup: ' . mysql_error()); } echo "Backedup data successfully\n"; mysql_close($connection); ?> |
Note:In the phymyaadmin you can use the manual backup operaiton using Export and database restore using import statement.