DustyEngineer
DustyEngineer

Reputation: 35

Google Cloud SQL Connection Issues (C#)

I am connecting to a Google Cloud SQL (MySQL) server. I get the error "Unable to connect to any of the specified MySQL hosts." Does anybody know what's going on? The connection string syntax exactly matches the syntax of the GCloud example and I have enabled any IP address access. My firewall is not blocking the connection.

My code is as follows:

     string conStr = "Server=xxx.xxx.xxx.xxx;Database=DB_NAME;Uid=USER_NAME;Password=PASSWORD;

        try
        {
            MySqlConnection conn = new MySqlConnection(conStr);
            conn.Open();
            MessageBox.Show("Connected.");
        }
        catch (MySql.Data.MySqlClient.MySqlException ex)
        {
            MessageBox.Show(ex.Message);
        }

Upvotes: 0

Views: 748

Answers (1)

DustyEngineer
DustyEngineer

Reputation: 35

The problem was that I had configured the users to be able to login from any host address, but I did not whitelist my IP in the "Authorization" page in the Google Cloud Console.

The client IP needs to be whitelisted for the instance if you don't want to use the Cloud SQL Proxy.

Hopefully that helps someone.

Upvotes: 1

Related Questions