Minggu, Januari 08, 2012

MySQL : mysqldump with -w option on Windows XP

Case : You have a big size of mysql database table on windows xp machine and you want to dump database table with "where" condition
Solution : using -w option


$username = "root";
$password = "toor";
$hostname = "localhost";
$sConnString = mysql_connect($hostname, $username, $password)
 or die("Unable to connect to MySQL");

$connection = mysql_select_db("Country",$sConnString)
 or die("Could not select DB");

$sql = "select * from tblkelurahan where left(KelurahanID,4)='3277'";
$query = mysql_query($sql);

while ($fetch = mysql_fetch_object($query)) {
 $namafile = $fetch->KelurahanID;
 $command = "C:xampp\\mysql\\bin\\mysqldump.exe --add-drop-table -uroot -ptoor -w\"KelurahanID='$namafile'\" Indonesia tblpenduduk > $namafile.sql";