Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql备份中超时-C#_C#_Mysql_Connection Timeout - Fatal编程技术网

Mysql备份中超时-C#

Mysql备份中超时-C#,c#,mysql,connection-timeout,C#,Mysql,Connection Timeout,我构建了一个从服务器备份MYSQL数据库的应用程序,数据库一天比一天大,有时会触发错误(从我的角度来看): 消息:超时已过期。操作完成前已过超时时间,或者服务器没有响应。 完整:MySql.Data.MySqlClient.MySqlException(0x80004005):超时已过期。操作完成前的超时时间或服务器没有响应。-->System.TimeoutException:IO操作中的超时 在MySql.Data.MySqlClient.TimedStream.StopTimer()上 位

我构建了一个从服务器备份MYSQL数据库的应用程序,数据库一天比一天大,有时会触发错误(从我的角度来看):

消息:超时已过期。操作完成前已过超时时间,或者服务器没有响应。 完整:MySql.Data.MySqlClient.MySqlException(0x80004005):超时已过期。操作完成前的超时时间或服务器没有响应。-->System.TimeoutException:IO操作中的超时 在MySql.Data.MySqlClient.TimedStream.StopTimer()上 位于MySql.Data.MySqlClient.TimedStream.Read(字节[]缓冲区,Int32偏移量,Int32计数) 在System.IO.BufferedStream.Read(字节[]数组,Int32偏移量,Int32计数) 位于MySql.Data.MySqlClient.MySqlStream.ReadFully(流流,字节[]缓冲区,Int32偏移量,Int32计数) 在MySql.Data.MySqlClient.MySqlStream.LoadPacket()处 位于MySql.Data.MySqlClient.MySqlStream.ReadPacket()处 位于MySql.Data.MySqlClient.NativeDriver.FetchDataRow(Int32 statementId,Int32列) 位于MySql.Data.MySqlClient.Driver.FetchDataRow(Int32 statementId,Int32列) 在MySql.Data.MySqlClient.ResultSet.GetNextRow()中 位于MySql.Data.MySqlClient.ResultSet.NextRow(CommandBehavior) 在MySql.Data.MySqlClient.MySqlDataReader.Read()处 位于MySql.Data.MySqlClient.ExceptionInterceptor.Throw(异常) 位于MySql.Data.MySqlClient.MySqlConnection.Throw(异常示例) 位于MySql.Data.MySqlClient.MySqlConnection.HandleTimeoutOrThreadAbort(异常示例) 在MySql.Data.MySqlClient.MySqlDataReader.Read()处 位于MySql.Data.MySqlClient.MySqlBackup.Export_RowsData(字符串tableName,字符串selectSQL) 在MySql.Data.MySqlClient.MySqlBackup.Export_行(字符串tableName,字符串selectSQL) 在MySql.Data.MySqlClient.MySqlBackup.Export_TableRows()上 在MySql.Data.MySqlClient.MySqlBackup.ExportStart()处 位于MySql.Data.MySqlClient.MySqlBackup.ExportToFile(字符串文件路径) 在c:\Users\Belal\Documents\Visual Studio 2012\Projects\MYSQL Auto-Backup\MYSQL Auto-Backup\Form1.cs中的MYSQL\u Auto\u Backup.Form1.Backup()中:第132行

代码:


您可以使用“CommandTimeout”属性更改超时

<>有很多其他的备份方法(例如从数据库的管理工具),你也可以考虑。例如,请参见以下内容:

还有一个小问题。对于以下行:

string path;
path = txb_Path.Text + year + "-" + month + "-" + day + "--" + hour + "-" + minute + "-" + second + ".sql";
file = path;
为什么不做类似的事情呢

file = String.Format("{0}{1}-{2}-3--{4}-{5}...", txb_Path.Text, year, month...);
在.NET中,像您这样的字符串连接实际上相当昂贵,因为.NET字符串是不可变的

file = String.Format("{0}{1}-{2}-3--{4}-{5}...", txb_Path.Text, year, month...);