Just another WordPress.com site

Need information about programming ? visit this site : agiptek.com

This is a very smart script to copy a mysql database (with contents) to another database or it simply duplicates/backups a mysql database

<?
// Change the source & destination database
// You don’t need to create the destination database, only change the name below

$source_db=”db1″;
$new_db=”db2″;

mysql_connect(“localhost”,”root”,””);
mysql_select_db($source_db);

$result=mysql_query(“show tables”);

$table_names=array();
while($row=mysql_fetch_array($result)){
$table_names[]=$row[0];
}

mysql_query(“create database $new_db”);
mysql_select_db($new_db);

for($i=0;$i

Iklan

Comments on: "Code/Script to Copy MySql Database" (1)

  1. artikelnya bagus.. pengen sekali bisa MySql.. šŸ˜¦
    kunjungi blog say juga ya,kalo bisa di link juga dah.. šŸ™‚
    http://rondinoego08.wordpress.com

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: