Jump to content

SQL export whole table


gongpex

Recommended Posts

Hello everyone,

 

I look on google if we want to backup up data from mysql we run code like this :

<?php
   $dbhost = 'localhost';
   $dbuser = 'root';
   $dbpass = 'root';
   
   $conn = mysql_connect($dbhost, $dbuser, $dbpass);
   
   if(! $conn ) {
      die('Could not connect: ' . mysql_error());
   }
	
   $table_name = "kol1";
   $backup_file  = "F:/test.sql";
   $sql = "SELECT * INTO OUTFILE '$backup_file' FROM $table_name";
   
   mysql_select_db('test');
   $retval = mysql_query( $sql, $conn );
   
   if(! $retval ) {
      die('Could not take data backup: ' . mysql_error());
   }
   
   echo "Backedup  data successfully\n";
   
   mysql_close($conn);
?>

This code works, but only backup one table (kol1),

 

Q : Is there any solution to backup all table from database?

 

please help me

 

Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...