[Solved] Connection string for MySQL in C#


The below connection string might be helpful for your problem.

"server=localhost:3320;uid=root;pwd=Mypwd;database=cc;persistsecurityinfo=true;convertzerodatetime=true"

Else remove persistsecurityinfo and convertzerodatetime then try.

"server=localhost:3320;uid=root;pwd=Mypwd;database=cc"

Refer this too in MySQL documentation.

// Sessions
MySQLX.GetSession($"mysqlx://user@host/schema")
MySQLX.GetSession($"mysqlx://user@host/schema?connection-attributes")
MySQLX.GetSession($"mysqlx://user@host/schema?connection-attributes=true")
MySQLX.GetSession($"mysqlx://user@host/schema?connection-attributes=false")
MySQLX.GetSession($"mysqlx://user@host/schema?connection-attributes=[attr1=val1,attr2,attr3=]")
MySQLX.GetSession($"mysqlx://user@host/schema?connection-attributes=[]")

// Pooling
MySQLX.GetClient($"mysqlx://user@host/schema")
MySQLX.GetClient($"mysqlx://user@host/schema?connection-attributes")
MySQLX.GetClient($"mysqlx://user@host/schema?connection-attributes=true")
MySQLX.GetClient($"mysqlx://user@host/schema?connection-attributes=false")
MySQLX.GetClient($"mysqlx://user@host/schema?connection-attributes=[attr1=val1,attr2,attr3=]")
MySQLX.GetClient($"mysqlx://user@host/schema?connection-attributes=[]")

Reference: https://dev.mysql.com/doc/connector-net/en/connector-net-8-0-connection-options.html

solved Connection string for MySQL in C#