Google Cloud Platform (GCP) provides a robust environment for managing databases and offers faculty an opportunity to explore SQL Server’s capabilities for research and teaching. This guide will walk you through setting up a Google Cloud SQL Server connection and creating a database to use for your projects. The instructions are based on a setup for an NC State University project and adapted for general use by faculty or students.


Prerequisites

Before starting, ensure you have:

  1. Access to a GCP project: Contact your institution’s IT department if you need access.
  2. Google Cloud SDK: Download and install the SDK for your operating system from Google Cloud SDK Docs.
  3. Google Cloud SQL Proxy: You’ll need this to securely connect to your database. Instructions for installation are provided below.
  4. Azure Data Studio: A database management tool for interacting with your SQL Server.

Step 1: Install Google Cloud SDK

  1. Download the correct version of the Google Cloud SDK for your operating system from Google Cloud SDK Docs.
  2. Move the downloaded folder to your project directory. For example:
    Documents/MA590_SQL/Proxy
  3. Open a terminal and navigate to the SDK’s bin folder:
    cd Documents/MA590_SQL/Proxy/google-cloud-sdk/bin
  4. Initialize the SDK:
    ./gcloud init
  5. Log in with your institutional email and select the appropriate GCP project.

Step 2: Authenticate with the GCP Project

To authenticate, run the following command:

./gcloud auth login

Make sure to select the project allocated for your department or course.


Step 3: Install Google Cloud SQL Proxy

  1. Navigate to the Proxy directory:
    cd Documents/MA590_SQL/Proxy
  2. Download the proxy:
    curl -o cloud-sql-proxy https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.7.0/cloud-sql-proxy.[OS].arm64

    Replace [OS] with your operating system (e.g., darwin for macOS).

  3. Make the proxy executable:
    chmod +x cloud-sql-proxy

Step 4: Configure the Environment

  1. Add the gcloud executable to your system’s PATH:
    • Open your bash profile:
      vi $HOME/.bash_profile
    • Add the following line:
      export PATH="$PATH:/path/to/google-cloud-sdk/bin"
    • Save and apply changes:
      source $HOME/.bash_profile
  2. Verify the setup:
    echo $PATH

Step 5: Start the Cloud SQL Proxy

To connect the proxy to your GCP database, run the following command:

./cloud-sql-proxy --port 1433 [PROJECT-ID]:[REGION]:[INSTANCE-ID] --gcloud-auth

Replace [PROJECT-ID], [REGION], and [INSTANCE-ID] with your project’s details.


Step 6: Connect to the Database Using Azure Data Studio

  1. Download Azure Data Studio from Microsoft’s site.
  2. Open Azure Data Studio and create a new connection with the following details:
    • Connection Type: Microsoft SQL Server
    • Server: 127.0.0.1
    • Authentication Type: SQL Login
    • Username and Password: (Your database credentials)

Step 7: Start Using Your SQL Server Database

You are now connected to your database and can run queries, manage tables, and utilize SQL Server’s capabilities for your projects.


This guide simplifies the process for faculty members to explore SQL Server on GCP. If you encounter issues, feel free to reach out to your IT support or leave comments below.