When I try to export the last table, it writes a little bit and then thinks it's done. I usually end up with a file that's between 10 and 36MB. It should be around 660MB. Try as I might, I can't get it to finish the export.
In light of this problem, I have tried to write my own script that will take the contents of my table and write them to a dump file, which I can then use to load the table onto the other computer. However, the script that I have written does not put out files that will load correctly into my new database. I think that there's some error in my table content. I have included this script below.
I know there must be some other way to do this. The normal way seems to lock up and not finish, as described above. Does anyone know another way of doing this? If not, can you see anything wrong in my self-made table export script?
Code: Select all
$tableName='mytable';
$dbName='mydb';
$comment='my comment'
$conn = mysql_connect("localhost", "", "");
$db = mysql_select_db($dbName, $conn)or die("Could not Select DB: " . mysql_error());
$fileOpen = fopen( "c:/Documents and Settings/Me/Desktop/".$tableName.".sql" , "w" );
if(!$fileOpen){
echo "Couldn't open the data file. Try again later.";
exit;
}
$fileStart= "
-- phpMyAdmin SQL Dump
-- version 2.6.1-pl3
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Server version: 4.1.10
-- PHP Version: 5.0.4
--
-- Database: `".$dbName."`
--
-- --------------------------------------------------------
--
-- Table structure for table `".$tableName."`
--
CREATE TABLE `".$tableName."` (
`longitude` float NOT NULL default '0',
`latitude` float NOT NULL default '0',
`winWeibC` float NOT NULL default '0',
`winWeibK` float NOT NULL default '0',
`sprWeibC` float NOT NULL default '0',
`sprWeibK` float NOT NULL default '0',
`sumWeibC` float NOT NULL default '0',
`sumWeibK` float NOT NULL default '0',
`falWeibC` float NOT NULL default '0',
`falWeibK` float NOT NULL default '0',
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `".$tableName."`
--
";
fwrite( $fileOpen, $fileStart );
$sql = "SELECT * FROM ".$tableName;
$result = mysql_query($sql, $conn) or die("mysql query didn't work!");
$numCols=mysql_num_fields($result);
while($row = mysql_fetch_assoc($result)){
$i=$numCols;
$inputString= "INSERT INTO `".$tableName."` VALUES (";
foreach ($row as $col=>$val){
$inputString= $inputString.$val;
if($i!=1){
$inputString= $inputString." , ";
}
$i--;
}
$i=0;
$inputString= $inputString.");\n";
fwrite( $fileOpen, $inputString );
}
fclose( $fileOpen );