# Connect to Cloud SQL for MySQL from your local computer

<br />

Learn how to deploy a sample app on your Linux, macOS, or Windows-based local computer
connected to a MySQL instance by using the Google Cloud console and a client
application.

Assuming that you complete all the steps in a timely manner, the resources
created in this quickstart typically cost less than one dollar (USD).

## Before you begin

> [!NOTE]
> **Note:** The name you use for your project must be between 4 and 30 characters. When you type the name, the form suggests a project ID, which you can edit. The project ID must be between 6 and 30 characters, with a lowercase letter as the first character. You can use a dash, lowercase letter, or digit for the remaining characters, but the last character cannot be a dash.

1. [Verify that you have the permissions required
   to complete this quickstart](https://docs.cloud.google.com/sql/docs/mysql/connect-instance-local-computer#required-roles).
2. Enable the Cloud APIs necessary to run a Cloud SQL sample app on your local computer.

   ### Console

   Click the **Enable APIs** button to enable the APIs required for this quickstart.

   [Enable APIs](https://console.cloud.google.com/apis/enableflow?apiid=sqladmin.googleapis.com,iam.googleapis.com)

   This enables the following APIs:
   - Cloud SQL Admin API
   - IAM API

   ### gcloud

   [Install the](https://docs.cloud.google.com/sdk/docs/install)[gcloud CLI](https://docs.cloud.google.com/sdk/gcloud.md.txt) which provides
   command-line access to your Google Cloud resources. The [gcloud CLI](https://docs.cloud.google.com/sdk/gcloud.md.txt) is used
   to run the `gcloud CLI` commands presented throughout this quickstart.
   All the commands are formatted to be run in a Linux/macOS terminal or in Windows Powershell.


   Open the terminal and run the following `gcloud` command:

   ```bash
   gcloud services enable sqladmin.googleapis.com iam.googleapis.com
   ```

   This command enables the following APIs:
   - Cloud SQL Admin API
   - IAM API

### Required roles


To get the permissions that
you need to set up Cloud SQL from your local computer,

ask your administrator to grant you the
following IAM roles on the project that you want to create and connect to:

- Create or delete an instance, database, and user: Cloud SQL administrator role (`roles/cloudsql.admin`).
- Create or delete an IAM service account: IAM Service Account administrator role (`roles/iam.serviceAccountAdmin`).
- Add or remove an IAM policy binding: Project IAM administrator role (`roles/resourcemanager.projectIamAdmin`).
- Create, manage and rotate service account keys: Service Account Key Admin (roles/iam.serviceAccountKeyAdmin).


For more information about granting roles, see [Manage access to projects, folders, and organizations](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access.md.txt).


You might also be able to get
the required permissions through [custom
roles](https://docs.cloud.google.com/iam/docs/creating-custom-roles) or other [predefined
roles](https://docs.cloud.google.com/iam/docs/roles-overview#predefined).

<br />

## Set up Cloud SQL

To create an Cloud SQL instance, do the following:

1. In the Google Cloud console, go to the **Cloud SQL Instances** page.

   [Go to Cloud SQL Instances](https://console.cloud.google.com/sql)
2. Select the MySQL tab and click **Create Sandbox instance** in the **Sandbox** box. Alternatively, you can click**Create Instance** and complete the following steps:
   1. Click **Choose MySQL**.
   2. Select the **Enterprise** edition.
   3. Choose the **Sandbox** preset.
3. If you're prompted to enable the **Compute API** , click the **Enable API** button.
4. In the **Instance info** section, enter `quickstart-instance` as the **Instance ID**.
5. Enter a password for the root user. Take note of the password you create, because you'll need it later.
6. In the **Choose region and zonal availability** section, select the **Single zone** option.
7. Click **Create instance**.

### Create a database

### Console

1. In the Google Cloud console, go to the **Cloud SQL Instances** page.

   [Go to Cloud SQL Instances](https://console.cloud.google.com/sql)
2. Select `quickstart-instance`.
3. Open the **Databases** tab.
4. Click **Create database**.
   1. In the **Create a database** dialog box, enter `quickstart_db` as the name of the database, and optionally the character set and collation.
   2. Click **Create**.

### gcloud

Run the [`gcloud
sql databases create`](https://docs.cloud.google.com/sdk/gcloud/reference/sql/databases/create) command to create a database.

```bash
gcloud sql databases create quickstart_db --instance=quickstart-instance
```

### Create a user

### Console

1. In the Google Cloud console, go to the **Cloud SQL Instances** page.

   [Go to Cloud SQL Instances](https://console.cloud.google.com/sql)
2. To open the **Overview** page of an instance, click the instance name.
3. Select **Users** from the **SQL** navigation menu.
4. Click **Add user account**.
   - In the **Add a user account to instance *instance_name*** page, add the following information:
     - **Username** : Set to `quickstart-user`
     - **Password**: Specify a password for your database user. Make a note of this for use in a later step of this quickstart.
     - In the **Host name** section, the default is **Allow any host** , which means that the user can connect from any IP address.

       Optionally, select **Restrict host by IP address or address range**
       and enter an IP address or address range in the **Host** section.
       The user can then connect only from the IP address or
       addresses specified.
5. Click **Add**.

### gcloud

Replace the following:

1. <var translate="no">PASSWORD</var> with a password for your database user. Make a note of this for use in a later step of this quickstart.

Run the [`gcloud sql users create`](https://docs.cloud.google.com/sdk/gcloud/reference/sql/users/create) command to create the user.

```bash
gcloud sql users create quickstart-user --instance=quickstart-instance --password=PASSWORD
```

Username length limits are the same for Cloud SQL as for
on-premises MySQL; 32 characters for MySQL 8.0 and later,
16 characters for earlier versions.

## Set up a service account

Create and configure a Google Cloud service account that has the **Cloud SQL Client** role with permissions to connect to Cloud SQL. After you create a service account, you might need to wait for 60 seconds or more before you use the service account.

### Console

#### Create a service account

1. In the Google Cloud console, go to the **Create service account** page.
2. [Go to Create service account](https://console.cloud.google.com/projectselector/iam-admin/serviceaccounts/create)
3. Select a Google Cloud project.
4. Enter a `quickstart-service-account` as the service account name.
5. Optional: Enter a description of the service account.
6. Click **Create and continue** and continue to the next step.
7. Choose the Cloud SQL Client role to grant to the service account on the project.
8. Click **Continue**.
9. Click **Done** to finish creating the service account.

#### Create and download the service account key file

1. In the Google Cloud console, go to the **Service accounts** page.
2. [Go to Service accounts](https://console.cloud.google.com/iam-admin/serviceaccounts)
3. Select a project.
4. Click the email address of the `quickstart-service-account` service account that you want to create a key for.
5. Click the **Keys** tab.
6. Click the **Add key** drop-down menu, then select **Create new key**.
7. Select **JSON** as the **Key type** and click **Create**.

Clicking **Create** downloads a service account key file. After you download the
key file, you cannot download it again.

Make sure to store the key file securely, because it can be used to authenticate as your service account.
You can move and rename this file however you would like.

### gcloud

#### Create a service account

1. To create the service account, run the [`gcloud iam service-accounts create`](https://docs.cloud.google.com/sdk/gcloud/reference/iam/service-accounts/create) command:

```bash
gcloud iam service-accounts create quickstart-service-account --description="DESCRIPTION" --display-name="quickstart-service-account"
```
2. Replace the following value:
   - <var translate="no">`DESCRIPTION`</var>: An optional description of the service account
3. To grant your service account the Cloud SQL Client role on your project, run the [`gcloud projects add-iam-policy-binding`](https://docs.cloud.google.com/sdk/gcloud/reference/projects/add-iam-policy-binding) command. Replace <var translate="no">PROJECT_ID</var> with your Google Cloud project ID:

   ```bash
   gcloud projects add-iam-policy-binding PROJECT_ID --member="serviceAccount:quickstart-service-account@PROJECT_ID.iam.gserviceaccount.com" --role="roles/cloudsql.client"
   ```

#### Create and download the service account key file

To use the service account you just created from your local computer you need a service account key file to
authenticate the sample application as the service account. To create and download the service account key file, run the
[`gcloud iam service-accounts keys create`](https://docs.cloud.google.com/sdk/gcloud/reference/iam/service-accounts/keys/create) command:

```bash
gcloud iam service-accounts keys create KEY_FILE --iam-account=quickstart-service-account@PROJECT_ID.iam.gserviceaccount.com
```

Replace the following values:

- <var translate="no">`KEY_FILE`</var>: The path to a new output file for the private key --- for example, `~/sa-private-key.json`.
- <var translate="no">`PROJECT_ID`</var>: Your Google Cloud project ID.

The service account key file is now downloaded to your local computer. After you download the key file, you cannot download it again.

Make sure to store the key file securely, because anyone can use it to authenticate as your service account.
You can move and rename this file however you would like.

## Setup development environment for programming language


Set up your local computer's development environment for your preferred programming language.

### Go


Complete the following steps to set up your development environment to run the Go sample app.

1. Go to the [setup guide for a Go development environment](https://docs.cloud.google.com/go/docs/setup.md.txt).
2. Complete the instructions in the **Install Go** section.

### Java


Complete the following steps to set up your development environment to run the Java sample app.

1. Go to the [setup guide for a Java development environment](https://docs.cloud.google.com/java/docs/setup.md.txt).
2. Complete the instructions in the **Install a JDK (Java Development Kit)** section.
3. Complete the instructions in the **Install a build automation tool** to set up Apache Maven.

### Node.js


Complete the following steps to set up your development environment to run the Node.js sample app.

1. Go to [setup guide for a Node.js development environment](https://docs.cloud.google.com/nodejs/docs/setup.md.txt).
2. Complete the instructions in the **Installing Node.js and npm** section.

### Python


Complete the following steps to set up your development environment to run the Python sample app.

1. Go to [setup guide for a Python development environment](https://docs.cloud.google.com/python/docs/setup.md.txt).
2. Complete the instructions in the **Installing Python** section.

## Install Git


Install [Git](https://git-scm.com/), an open source version control system.

#### Linux


Follow the official [Git installation documentation for Linux](https://git-scm.com/download/linux).

#### macOS


Follow the official [Git installation documentation for macOS](https://git-scm.com/download/mac).

#### Windows


Follow the official [Git installation documentation for Windows](https://git-scm.com/download/win).

## Clone a sample app


Clone a sample app to your local computer using the [`git clone`](https://git-scm.com/docs/git-clone) command.

<br />

### Go

Run the following commands to clone the Go sample app to your local computer and change directory to the directory containing the sample app.

1. Clone the sample app.

   ```bash
   git clone https://github.com/GoogleCloudPlatform/golang-samples
   ```
2. Change directory to the directory containing the sample app.

   ```bash
   cd golang-samples/cloudsql/mysql/database-sql
   ```

### Java

Run the following commands to clone the Java sample app to your local computer and change directory to the directory containing the sample app.

1. Clone the sample app.

   ```bash
   git clone https://github.com/GoogleCloudPlatform/java-docs-samples
   ```
2. Change directory to the directory containing the sample app.

   ```bash
   cd java-docs-samples/cloud-sql/mysql/servlet
   ```

### Node.js

Run the following commands to clone the Node.js sample app to your local computer and change directory to the directory containing the sample app.

1. Clone the sample app.

   ```bash
   git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples
   ```
2. Change directory to the directory containing the sample app.

   ```bash
   cd nodejs-docs-samples/cloud-sql/mysql/mysql
   ```

### Python

Run the following commands to clone the Python sample app to your local computer and change directory to the directory containing the sample app.

1. Clone the sample app.

   ```bash
   git clone https://github.com/GoogleCloudPlatform/python-docs-samples
   ```
2. Change directory to the directory containing the sample app.

   ```bash
   cd python-docs-samples/cloud-sql/mysql/sqlalchemy
   ```

<br />

## Configure and run sample app


Configure and run the sample app.

#### Linux/macOS

### Go


Open the terminal and run the following commands to initialize environment variables required to run the sample app. Before running the commands, make the following replacements:

- <var translate="no">CREDENTIALS_JSON_FILE</var> with the file path of your service account's JSON credentials key file using a format like `/path/to/service/account/key.json`.
- <var translate="no">INSTANCE_CONNECTION_NAME</var> with your instance's **Connection name** that appears on the Cloud SQL instance **Overview** page.
- <var translate="no">YOUR_DB_PASSWORD</var> with the password of the `quickstart-user` that you created in the previous **Create a user** quickstart step.

```bash
export GOOGLE_APPLICATION_CREDENTIALS=CREDENTIALS_JSON_FILE
export INSTANCE_CONNECTION_NAME='INSTANCE_CONNECTION_NAME'
export DB_PORT='3306'
export DB_NAME='quickstart_db'
export DB_USER='quickstart-user'
export DB_PASS='YOUR_DB_PASSWORD'
```


Run the following commands to get the Go sample app's dependencies on your local computer and run the sample app.

1. Get the dependencies required to run the sample app.

   ```bash
   go get ./...
   ```
2. Run the sample app.

   ```bash
   go run cmd/app/main.go
   ```
3. View the running sample app. Open a browser window and go to `http://127.0.0.1:8080`.

   ![View deployed sample app](https://docs.cloud.google.com/static/sql/images/tabs-vs-spaces-app-screen-shot.png)
4. To stop the sample app, press <kbd>Control+C</kbd> in the terminal window where you started the sample app.

### Java


Run the following commands to initialize environment variables required to run the sample app. Before running the commands, make the following replacements:

- <var translate="no">CREDENTIALS_JSON_FILE</var> with the file path of your service account's JSON credentials key file using a format like `/path/to/service/account/key.json`.
- <var translate="no">INSTANCE_CONNECTION_NAME</var> with your instance's **Connection name** that appears on the Cloud SQL instance **Overview** page.
- <var translate="no">YOUR_DB_PASSWORD</var> with the password of the `quickstart-user` that you created in the previous **Create a user** quickstart step.

```bash
export GOOGLE_APPLICATION_CREDENTIALS=CREDENTIALS_JSON_FILE
export INSTANCE_CONNECTION_NAME='INSTANCE_CONNECTION_NAME'
export DB_PORT='3306'
export DB_NAME='quickstart_db'
export DB_USER='quickstart-user'
export DB_PASS='YOUR_DB_PASSWORD'
```

1.
   Run the following command to get the Java sample app's dependencies on your local computer and run the sample app.

   ```bash
   mvn jetty:run
   ```
2. View the running sample app. Open a browser window and go to `http://127.0.0.1:8080`.

   ![View deployed sample app](https://docs.cloud.google.com/static/sql/images/tabs-vs-spaces-app-screen-shot.png)
3. To stop the sample app, press <kbd>Control+C</kbd> in the terminal window where you started the sample app.

### Node.js

1.
   Run the following commands to initialize environment variables required to run the sample app. Before running the commands, make the following replacements:

   - <var translate="no">CREDENTIALS_JSON_FILE</var> with the file path of your service account's JSON credentials key file using a format like `/path/to/service/account/key.json`.
   - <var translate="no">YOUR_DB_PASSWORD</var> with the password of the `quickstart-user` that you created in the previous **Create a user** quickstart step.

   ```bash
   export GOOGLE_APPLICATION_CREDENTIALS=CREDENTIALS_JSON_FILE
   export INSTANCE_HOST='127.0.0.1'
   export DB_PORT='3306'
   export DB_NAME='quickstart_db'
   export DB_USER='quickstart-user'
   export DB_PASS='YOUR_DB_PASSWORD'
   ```
2. Download the Cloud SQL Auth Proxy.

   ```bash
   curl -o cloud-sql-proxy \
   https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.0.0/cloud-sql-proxy.linux.amd64
   ```
3. Run the Cloud SQL Auth Proxy as a background process. Replace <var translate="no">INSTANCE_CONNECTION_NAME</var> with your instance's **Connection name** that appears on the Cloud SQL instance **Overview** page.

   ```bash
   ./cloud-sql-proxy \
   --credentials-file $GOOGLE_APPLICATION_CREDENTIALS \
   INSTANCE_CONNECTION_NAME &
   ```

> [!NOTE]
> **Note:** The process running the Cloud SQL Auth Proxy in the background can be stopped using the `fg` command in your Terminal window where you started the sample app. This should bring the running Cloud SQL Auth Proxy job to the terminal foreground. Then press <kbd>Control+C</kbd> to stop the proxy job.


Run the following commands to get the required Node.js packages on to your local computer and run the sample app.

1. Install the Node.js packages necessary to run the app locally.

   ```bash
   npm install
   ```
2. Run the sample app.

   ```bash
   npm start
   ```
3. View the running sample app. Open a browser window and go to `http://127.0.0.1:8080`.

   ![View deployed sample app](https://docs.cloud.google.com/static/sql/images/tabs-vs-spaces-app-screen-shot.png)
4. To stop the sample app, press <kbd>Control+C</kbd> in the terminal window where you started the sample app.

### Python


Run the following commands to initialize environment variables required to run the sample app. Before running the commands, make the following replacements:

- <var translate="no">CREDENTIALS_JSON_FILE</var> with the file path of your service account's JSON credentials key file using a format like `/path/to/service/account/key.json`.
- <var translate="no">INSTANCE_CONNECTION_NAME</var> with your instance's **Connection name** that appears on the Cloud SQL instance **Overview** page.
- <var translate="no">YOUR_DB_PASSWORD</var> with the password of the `quickstart-user` that you created in the previous **Create a user** quickstart step.

```bash
export GOOGLE_APPLICATION_CREDENTIALS=CREDENTIALS_JSON_FILE
export INSTANCE_CONNECTION_NAME='INSTANCE_CONNECTION_NAME'
export DB_PORT='3306'
export DB_NAME='quickstart_db'
export DB_USER='quickstart-user'
export DB_PASS='YOUR_DB_PASSWORD'
```


Run the following commands to get the Python sample app's requirements on to your local computer and run the sample app.

1. Initialize a virtual environment and install the requirements to run the sample app.

   ```bash
   python3 -m venv env
   source env/bin/activate
   pip install -r requirements.txt
   ```
2. Run the sample app.

   ```bash
   python app.py
   ```
3. View the running sample app. Open a browser window and go to `http://127.0.0.1:8080`.

   ![View deployed sample app](https://docs.cloud.google.com/static/sql/images/tabs-vs-spaces-app-screen-shot.png)
4. To stop the sample app, press <kbd>Control+C</kbd> in the terminal window where you started the sample app.

#### Windows

### Go


Run the following commands to initialize environment variables required to run the sample app. Before running the commands, make the following replacements:

- <var translate="no">CREDENTIALS_JSON_FILE</var> with the file path of your service account's JSON credentials key file using a format like `C:\Users\Your-Username\Downloads\key.json`.
- <var translate="no">INSTANCE_CONNECTION_NAME</var> with your instance's **Connection name** that appears on the Cloud SQL instance **Overview** page.
- <var translate="no">YOUR_DB_PASSWORD</var> with the password of the `quickstart-user` that you created in the previous **Create a user** quickstart step.

```bash
$env:GOOGLE_APPLICATION_CREDENTIALS="CREDENTIALS_JSON_FILE"
$env:INSTANCE_CONNECTION_NAME="INSTANCE_CONNECTION_NAME"
$env:DB_PORT="3306"
$env:DB_NAME="quickstart_db"
$env:DB_USER="quickstart-user"
$env:DB_PASS="YOUR_DB_PASSWORD"
```


Run the following commands to get the Go sample app's dependencies on your local computer and run the sample app.

1. Get the dependencies required to run the sample app.

   ```bash
   go get ./...
   ```
2. Run the sample app.

   ```bash
   go run cmd\app\main.go
   ```
3. View the running sample app. Open a browser window and go to `http://127.0.0.1:8080`.

   ![View deployed sample app](https://docs.cloud.google.com/static/sql/images/tabs-vs-spaces-app-screen-shot.png)
4. To stop the sample app, press <kbd>Control+C</kbd> in the Powershell window where you started the sample app.

### Java


Run the following commands to initialize environment variables required to run the sample app. Before running the commands, make the following replacements:

- <var translate="no">CREDENTIALS_JSON_FILE</var> with the file path of your service account's JSON credentials key file using a format like `C:\Users\Your-Username\Downloads\key.json`.
- <var translate="no">INSTANCE_CONNECTION_NAME</var> with your instance's **Connection name** that appears on the Cloud SQL instance **Overview** page.
- <var translate="no">YOUR_DB_PASSWORD</var> with the password of the `quickstart-user` that you created in the previous **Create a user** quickstart step.

```bash
$env:GOOGLE_APPLICATION_CREDENTIALS="CREDENTIALS_JSON_FILE"
$env:INSTANCE_CONNECTION_NAME="INSTANCE_CONNECTION_NAME"
$env:DB_PORT="3306"
$env:DB_NAME="quickstart_db"
$env:DB_USER="quickstart-user"
$env:DB_PASS="YOUR_DB_PASSWORD"
```

1.
   Run the following command to get the Java sample app's dependencies on your local computer and run the sample app.

   ```bash
   mvn jetty:run
   ```
2. View the running sample app. Open a browser window and go to `http://127.0.0.1:8080`.

   ![View deployed sample app](https://docs.cloud.google.com/static/sql/images/tabs-vs-spaces-app-screen-shot.png)
3. To stop the sample app, press <kbd>Control+C</kbd> in the Powershell window where you started the sample app.

### Node.js

1.
   Run the following commands to initialize environment variables required to run the sample app. Before running the commands, make the following replacements:

   - <var translate="no">CREDENTIALS_JSON_FILE</var> with the file path of your service account's JSON credentials key file using a format like `C:\Users\Your-Username\Downloads\key.json`.
   - <var translate="no">YOUR_DB_PASSWORD</var> with the password of the `quickstart-user` that you created in the previous **Create a user** quickstart step.

   ```bash
   $env:GOOGLE_APPLICATION_CREDENTIALS="CREDENTIALS_JSON_FILE"
   $env:INSTANCE_HOST="127.0.0.1"
   $env:DB_PORT="3306"
   $env:DB_NAME="quickstart_db"
   $env:DB_USER="quickstart-user"
   $env:DB_PASS="YOUR_DB_PASSWORD"
   ```
2. Download the Cloud SQL Auth Proxy.

   ```bash
   wget https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.0.0/cloud-sql-proxy.x64.exe 
   -O cloud-sql-proxy.exe
   ```
3. Run the Cloud SQL Auth Proxy as a background process. Replace <var translate="no">INSTANCE_CONNECTION_NAME</var> with your instance's **Connection name** that appears on the Cloud SQL instance **Overview** page.

   ```bash
   Start-Process -filepath  ".\cloud-sql-proxy.exe" -ArgumentList `
   "--credentials-file $env:GOOGLE_APPLICATION_CREDENTIALS" INSTANCE_CONNECTION_NAME
   ```

> [!NOTE]
> **Note:** The process running the Cloud SQL Auth Proxy in the background can be stopped by selecting the **cmd.exe** window that was spawned by the `Start-Process` command. Close the window to stop the proxy job.


Run the following commands to get the required Node.js packages on your local computer and run the sample app.

1. Install the Node.js packages necessary to run the app locally.

   ```bash
   npm install
   ```
2. Run the sample app.

   ```bash
   npm start
   ```
3. View the running sample app. Open a browser window and go to `http://127.0.0.1:8080`.

   ![View deployed sample app](https://docs.cloud.google.com/static/sql/images/tabs-vs-spaces-app-screen-shot.png)
4. To stop the sample app, press <kbd>Control+C</kbd> in the Powershell window where you started the sample app.

### Python


Run the following commands to initialize environment variables required to run the sample app. Before running the commands, make the following replacements:

- <var translate="no">CREDENTIALS_JSON_FILE</var> with the file path of your service account's JSON credentials key file using a format like `C:\Users\Your-Username\Downloads\key.json`.
- <var translate="no">INSTANCE_CONNECTION_NAME</var> with your instance's **Connection name** that appears on the Cloud SQL instance **Overview** page.
- <var translate="no">YOUR_DB_PASSWORD</var> with the password of the `quickstart-user` that you created in the previous **Create a user** quickstart step.

```bash
$env:GOOGLE_APPLICATION_CREDENTIALS="CREDENTIALS_JSON_FILE"
$env:INSTANCE_CONNECTION_NAME="INSTANCE_CONNECTION_NAME"
$env:DB_PORT="3306"
$env:DB_NAME="quickstart_db"
$env:DB_USER="quickstart-user"
$env:DB_PASS="YOUR_DB_PASSWORD"
```


Run the following commands to get the Python sample app's requirements on your local computer and run the sample app.

1. Initialize a virtual environment and install the requirements to run the sample app.

   ```bash
   virtualenv --python python3 env
   .\env\Scripts\activate
   pip install -r requirements.txt
   ```
2. Run the sample app.

   ```bash
   python app.py
   ```
3. View the running sample app. Open a browser window and go to `http://127.0.0.1:8080`.

   ![View deployed sample app](https://docs.cloud.google.com/static/sql/images/tabs-vs-spaces-app-screen-shot.png)
4. To stop the sample app, press <kbd>Control+C</kbd> in the Powershell window where you started the sample app.

## Clean up


To avoid incurring charges to your Google Cloud account for
the resources used on this page, follow these steps.

1. In the Google Cloud console, go to the **Cloud SQL Instances** page.

   [Go to Cloud SQL Instances](https://console.cloud.google.com/sql)
2. Select the `quickstart-instance` instance to open the **Instance details** page.
3. In the icon bar at the top of the page, click **Delete**.
4. In the **Delete instance** dialog box, type `quickstart-instance`, and then click **Delete** to delete the instance.

### Optional cleanup steps

If you're not using the **Cloud SQL client** role that you assigned to the
`quickstart-service-account` service account, you can remove it.

1. In the Google Cloud console, go to the **Service accounts** page.

   [Go to IAM](https://console.cloud.google.com/iam-admin/iam)
2. Click the edit icon (which looks like a pencil) for the IAM account named **quickstart-service-account**.
3. Delete the **Cloud SQL client** role.
4. Click **Save**.

If you're not using the APIs that were enabled as part of this quickstart, you
can disable them.

- APIs that were enabled within this quickstart:
  - Cloud SQL Admin API
  - Identity and Access Management API

1.

   In the Google Cloud console, go to the **APIs** page.

   [Go to APIs](https://console.cloud.google.com/apis)

   <br />

2. Select any API that you would like to disable and then click the **Disable API** button.

## What's next

Based on your needs, you can learn more about [creating Cloud SQL instances](https://docs.cloud.google.com/sql/docs/mysql/create-instance.md.txt).

<br />

You also can learn about creating [MySQL users](https://docs.cloud.google.com/sql/docs/mysql/create-manage-users.md.txt#creating)
and [databases](https://docs.cloud.google.com/sql/docs/mysql/create-manage-databases.md.txt#create) for your Cloud SQL instance.

For more information about pricing, see [Cloud SQL for MySQL pricing](https://cloud.google.com/sql/pricing).

Learn more about:

- Configuring your Cloud SQL instance with a [public IP](https://docs.cloud.google.com/sql/docs/mysql/configure-ip.md.txt) address.
- Configuring your Cloud SQL instance with a [private IP](https://docs.cloud.google.com/sql/docs/mysql/configure-private-ip) address.

Additionally, you can learn about connecting to a Cloud SQL instance from
other Google Cloud applications:

- [From an application running on App Engine standard environment](https://docs.cloud.google.com/sql/docs/mysql/connect-app-engine)
- [From an application running on Compute Engine](https://docs.cloud.google.com/sql/docs/mysql/connect-compute-engine.md.txt)
- [From an application running on GKE](https://docs.cloud.google.com/sql/docs/mysql/connect-kubernetes-engine.md.txt)
- [From Cloud Run](https://docs.cloud.google.com/sql/docs/mysql/connect-run.md.txt)