You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: managed_vms/cloudsql/README.md
+32-9Lines changed: 32 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -6,24 +6,47 @@ This sample demonstrates how to use [Google Cloud SQL](https://cloud.google.com/
6
6
7
7
Before you can run or deploy the sample, you will need to do the following:
8
8
9
-
1. Create a Cloud SQL instance. You can do this from the [Google Developers Console](https://console.developers.google.com) or via the [Cloud SDK](https://cloud.google.com/sdk). To create it via the SDK use the following command:
9
+
1. Create a [Second Generation Cloud SQL](https://cloud.google.com/sql/docs/create-instance) instance. You can do this from the [Cloud Console](https://console.developers.google.com) or via the [Cloud SDK](https://cloud.google.com/sdk). To create it via the SDK use the following command:
2. Create a new user and database for the application. The easiest way to do this is via the [Google Developers Console](https://console.developers.google.com/project/_/sql/instances/example-instance2/access-control/users). Alternatively, you can use MySQL tools such as the command line client or workbench, but you will need to set a root password for your database using `gcloud sql instances set-root-password`.
15
+
1. Set the root password on your Cloud SQL instance:
17
16
18
-
3. Update the connection string in ``app.yaml`` with your instance values.
4. Finally, run ``create_tables.py`` to ensure that the database is properly configured and to create the tables needed for the sample.
19
+
1. Create a [Service Account](https://cloud.google.com/sql/docs/external#createServiceAccount) for your project. You'll use this service account to connect to your Cloud SQL instance locally.
20
+
21
+
1. Download the [Cloud SQL Proxy](https://cloud.google.com/sql/docs/sql-proxy).
22
+
23
+
1. Run the proxy to allow connecting to your instance from your machine.
1. Use the MySQL command line tools (or a management tool of your choice) to create a [new user](https://cloud.google.com/sql/docs/create-user) and [database](https://cloud.google.com/sql/docs/create-database) for your application:
31
+
32
+
$ mysql -h 127.0.0.1 -u root -p
33
+
mysql> create database YOUR_DATABASE;
34
+
mysql> create user 'YOUR_USER'@'%' identified by 'PASSWORD';
35
+
mysql> grant all on YOUR_DATABASE.* to 'YOUR_USER'@'%';
36
+
37
+
1. Set the connection string environment variable. This allows the app to connect to your Cloud SQL instance through the proxy:
1. Run ``create_tables.py`` to ensure that the database is properly configured and to create the tables needed for the sample.
42
+
43
+
1. Update the connection string in ``app.yaml`` with your configuration values. These values are used when the application is deployed.
21
44
22
45
## Running locally
23
46
24
47
Refer to the [top-level README](../README.md) for instructions on running and deploying.
25
48
26
-
You will need to set the following environment variables via your shell before running the sample:
49
+
It's recommended to follow the instructions above to run the Cloud SQL proxy. You will need to set the following environment variables via your shell before running the sample:
0 commit comments