This page shows you how to create and connect to a SQL Server instance and perform basic SQL operations by using the Google Cloud console and a client. The resources created in this quickstart typically cost less than a dollar, assuming you complete the steps, including the cleanup, in a timely manner.
Before you begin 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.In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.Make sure that billing is enabled for your Google Cloud project.
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.Make sure that billing is enabled for your Google Cloud project.
In the Google Cloud console, go to the APIs page.
Enable the Cloud SQL Admin API. gcloudClick the following button to open Cloud Shell, which provides command-line access to your Google Cloud resources directly from the browser. Cloud Shell can be used to run the gcloud
commands presented throughout this quickstart.
Run the gcloud services enable
command as follows using Cloud Shell to enable the APIs required for this quickstart.:
gcloud services enable sqladmin.googleapis.com
This command enables the following APIs:
Make sure that you have the following role or roles on the project: Cloud SQL Admin (roles/cloudsql.admin
), Cloud SQL Viewer (roles/cloudsql.viewer
)
In the Google Cloud console, go to the IAM page.
Go to IAMIn the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
In the Google Cloud console, go to the IAM page.
Go to IAMIn the New principals field, enter your user identifier. This is typically the email address for a Google Account.
In this quickstart, you use the Google Cloud console. To use the gcloud CLI, cURL, or PowerShell, see Create instances.
In the Google Cloud console, go to the Cloud SQL Instances page.
myinstance
.sqlserver
user.Click Create instance.
You're returned to the instances list. You can click the new instance right away to see the details, but it won't be available for other operations until it initializes and starts.
Note: In this example, the instance is created using default settings, including a public IP address.address already in use
.gcloud init
gcloud auth login
Instance-connection-name
with the corresponding value from the Google Cloud console's Overview tab (for your instance):
./cloud-sql-proxy INSTANCE_CONNECTION_NAME
For more information about installing and using the Cloud SQL Auth Proxy, see About the Cloud SQL Auth Proxy.
As described in the next section, now you can connect to your SQL Server instance by using SSMS and the localhost IP address.
Connect using the SSMS Object ExplorerIn SSMS, select Connect Object Explorer from the File menu.
Enter the following values in the Connection dialog:
In the SSMS Object Explorer window, right-click the Databases node under your instance and select New Database.
Enter testdb for the Database name and click the OK button.
Under the newly created testdb database, right-click the Tables node and select New > Table.
Enter the following values in the Create table dialog:
Click the File menu and select Save guestbook.
Right-click the testdb table under Databases and select New Query.
Enter the following two INSERT statements into the SQL query text window and click the Execute button.
INSERT INTO guestbook (guestName, content) values ('first guest', 'I got here!'); INSERT INTO guestbook (guestName, content) values ('second guest', 'Me too!');
As an example:
Expand the Tables item under the Databases > testdb item in the Object Explorer window. Right-click the dbo.guestbook table and choose Select Top 1000 Rows.
The two records you inserted are displayed as Results, along with the SQL SELECT
statement used to query the records.
To avoid incurring charges to your Google Cloud account for the resources used on this page, follow these steps.
In the Google Cloud console, go to the Cloud SQL Instances page.
myinstance
instance to open the Instance details page.If you're not using the APIs that were enabled as part of this quickstart, you can disable them.
In the Google Cloud console, go to the APIs page.
Select the Cloud SQL Admin API and then click the Disable API button.
Learn about creating Cloud SQL instances.
Learn about creating SQL Server users and databases for your Cloud SQL instance.
See the Cloud SQL pricing information.
In this quickstart you connected to the instance by using Cloud Shell. Learn about all of the connectivity options in Cloud SQL. How you connect depends on your networking configuration, such as if your Cloud SQL instance has a public or private IP address. See how to configure your Cloud SQL instance with a public IP and a private IP address.
Learn about connecting to a Cloud SQL instance from other Google Cloud applications:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4