connecting to my cloud sql server with c# code example

Example: connecting to my cloud sql server with c#

var csb = new MySqlConnectionStringBuilder
{
    Server = "Google Cloud SQL IP address",
    UserID = "Your UserName",
    Password = "Your Password",
    Database = "Your Database/Schema Name",
    SslCert = @"C:\Path\To\client-cert.pem",
    SslKey = @"C:\Path\To\client-key.pem",
    SslCa = @"C:\Path\To\server-ca.pem",
    SslMode = MySqlSslMode.VerifyCA,
};

using var connection = new MySqlConnection(csb.ConnectionString);
connection.Open();

Tags:

Sql Example