我試圖恢復使用c#
通過下面的方法將數據庫文件(backup.sql)不工作...恢復功能使用mysql和C#
string hostaddress = "localhost";
try
{
string pathforbackupfile = @"C:\folder\Access\backupdb\backup.sql";
StreamReader file = new StreamReader(pathforbackupfile);
string input = file.ReadToEnd();
//file.Close();
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = @"C:\wamp\bin\mysql\mysql5.5.8\bin\mysql.exe";
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
psi.CreateNoWindow = true;
psi.Arguments = string.Format(@"-u {0} -h {1} {2}", "root", hostaddress, "access");
psi.UseShellExecute = false;
Process p = Process.Start(psi);
//p.StandardInput.WriteLine(input);
p.StandardInput.Write(input);
p.StandardInput.Close();
p.WaitForExit();
p.Close();
,但我沒能恢復數據庫..
什麼是錯的,上面的代碼..
編輯:
這是我T的一個他的表結構:
--
-- Table structure for table `banks`
--
DROP TABLE IF EXISTS `banks`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `banks` (
`bank_Id` int(11) NOT NULL AUTO_INCREMENT,
`bank_Tag` varchar(32) NOT NULL DEFAULT '',
`bank_Name` varchar(32) NOT NULL DEFAULT '',
`bank_Address1` varchar(32) NOT NULL,
`bank_Address2` varchar(32) NOT NULL,
`bank_Address3` varchar(32) NOT NULL,
`bank_Town` varchar(32) NOT NULL,
`bank_County` varchar(32) NOT NULL,
`bank_Postcode` varchar(32) NOT NULL,
`bank_Country` varchar(32) NOT NULL DEFAULT 'UK',
`bank_Contact` varchar(32) NOT NULL DEFAULT '',
`bank_Phone` varchar(32) NOT NULL DEFAULT '',
`bank_Email` varchar(32) NOT NULL DEFAULT '',
`bank_SortCode` varchar(16) NOT NULL DEFAULT '00-00-00',
`bank_Active` varchar(8) NOT NULL DEFAULT 'yes',
PRIMARY KEY (`bank_Id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `banks`
--
LOCK TABLES `banks` WRITE;
/*!40000 ALTER TABLE `banks` DISABLE KEYS */;
INSERT INTO `banks` VALUES (1,'ne','asd','asdf','df','df','df','df','sdf','df','df','df','sdf','sdf','y');
/*!40000 ALTER TABLE `banks` ENABLE KEYS */;
UNLOCK TABLES;
這裏有兩個函數「rows = ExecuteScript(conn,s);」和「NewConnection(dbHost,dbPort,」「,dbUser,dbPassword);」我有這兩個功能的錯誤..... – rockyashkumar
@rockyashkumar:在這裏他們,看看 – Marco
@Macro它不工作,我沒有在恢復前刪除數據庫,可能是這是原因,但我不知道,我不知道....你會提出任何想法 – rockyashkumar