Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase the connection timeout for mysql connection from c# application?

Tags:

c#

mysql

I want to increase the connection timeout for mysql connection and I can not modify the timeout settings from administrator panel of mysql server. I want to do it within c# application and I noticed that I can read the property ConnectionTimeout of MySqlConnection class. I would like to know that is there a way to increase the connection time before opening mysql connection.

like image 770
User1551892 Avatar asked Dec 06 '22 04:12

User1551892


2 Answers

you can change ConnectionString as below:

String connectionString = "Server=myserver; Port=3306; Database=databasename; Uid=userid; Pwd=password;Connection Timeout=30";

in the above Connection String you can specify the number of seconds as value for Connection Timeout

like image 188
Sudhakar Tillapudi Avatar answered Dec 10 '22 13:12

Sudhakar Tillapudi


use "default command timeout" in your connection string, it works for me

Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
default command timeout=20;

https://www.connectionstrings.com/mysql-connector-net-mysqlconnection/specifying-default-command-timeout/

like image 27
Diego Ripera Avatar answered Dec 10 '22 12:12

Diego Ripera