MYSQL insert大数据量的问题

ratooner 2013-10-05 10:31:49
请问C#程序里面插入比较多数据(500条记录)的时候提示如下错误:MySQLDriverCS Exception: MySQLDriverCS Error: can't connect.Can't connect to MySQL server on 'xxxx.xxxx.xxx.xx' (10048)

该如何排查?
...全文
720 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
Rotel-刘志东 2013-10-14
  • 打赏
  • 举报
回复
查询一下具体进程show processlist是否超过了连接数。
iihero_ 2013-10-10
  • 打赏
  • 举报
回复
进到mysql服务器,show processlist之类的,看看有多少连接,是不是超了? 另外,物理排查一下,是否还能连上mysql数据库。
發糞塗牆 2013-10-07
  • 打赏
  • 举报
回复
超过了连接数?
kobe8free 2013-10-06
  • 打赏
  • 举报
回复
查看 MySQLConnection 这个类 对 close 方法的封装 非c#人员的建议 说个题外话,不知道楼主的的 server是一个人用还是多人在用,上述方法只是代表服务器只被你一个人使用所以才去查找代码原因,如果是多人都在大批量插入,就。。。。。
ACMAIN_CHM 2013-10-05
  • 打赏
  • 举报
回复
你的conn并没有dipose掉啊。建议到.net群中去咨询一下,似乎conn.close后并不立即释放连接。
ratooner 2013-10-05
  • 打赏
  • 举报
回复
public static int ExecuteNonQuery(string cmdText, MySQLParameter[] parameters) { int i = 0; using (MySQLConnection conn = new MySQLConnection(DataBaseConnectionString.MySqlStr)) { try { conn.Open(); MySQLCommand command = new MySQLCommand { Connection = conn }; foreach (var p1 in parameters) { command.Parameters.Add(p1); } command.CommandText = cmdText; i = command.ExecuteNonQuery(); } catch (Exception ex) { i = -1; } finally { conn.Close(); } } return i; }
ratooner 2013-10-05
  • 打赏
  • 举报
回复
通过静态方法insert每次都关闭connection呢,难道sqlhelp是不能使用?
rucypli 2013-10-05
  • 打赏
  • 举报
回复
应该是链接太多了
ratooner 2013-10-05
  • 打赏
  • 举报
回复
是通过一些静态方法来访问数据库的
ACMAIN_CHM 2013-10-05
  • 打赏
  • 举报
回复
你的INSERT在C#中有没有及时关闭连接? 不会使用的什么 sqlhelp 之类的东西吧。
ratooner 2013-10-05
  • 打赏
  • 举报
回复
mysql> show status like 'max_used_connections'; +----------------------+-------+ | Variable_name | Value | +----------------------+-------+ | Max_used_connections | 93 | +----------------------+-------+ 1 row in set (0.00 sec) mysql> show variables like 'max_connections'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 1000 | +-----------------+-------+ 1 row in set (0.00 sec)

56,677

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧