Sie können den SQL Server-Befehlszeilenclient verwenden, um eine Verbindung zu Cloud SQL herzustellen. Auf dieser Seite wird beschrieben, wie Sie einen SQL Server-Client, der lokal auf Ihrem Clientcomputer oder auf einer Compute Engine-VM ausgeführt wird, mit Ihrer Cloud SQL-Instanz verbinden.
Hinweise
Führen Sie die folgenden Schritte aus, bevor Sie einen sqlcmd-Client verwenden, um eine Verbindung zu Ihrer Cloud SQL-Instanz herzustellen:
Erstellen Sie eine Cloud SQL-Instanz, in der der Standardnutzer konfiguriert ist.
Klicken Sie auf den Instanznamen, um die Seite Übersicht einer Instanz zu öffnen.
Wählen Sie im SQL-Navigationsmenü die Option Verbindung aus.
Wählen Sie den Tab Netzwerk aus.
Klicken Sie im Abschnitt Autorisierte Netzwerke auf Netzwerk hinzufügen und geben Sie die IP-Adresse des Computers an, auf dem der Client installiert ist.
Klicken Sie auf Fertig und dann am Seitenende auf Speichern, um die Änderungen zu speichern.
Damit eine Verbindung ohne Verschlüsselung hergestellt werden kann, muss für die Instanz requireSsl auf false festgelegt sein. In der Google Cloud -Konsole muss das Kästchen Nur SSL-Verbindungen zulassen deaktiviert sein.
Verwenden Sie den sqlcmd-Befehl, um eine Verbindung herzustellen. Führen Sie hierzu ähnliche Schritte wie in den Beispielen auf den Seiten SQL Server-Kurzanleitung und Dienstprogramm verwenden aus.
SSL/TLS-Verbindung zu Ihrer Cloud SQL-Instanz herstellen
Wenn Sie mit Google Cloud noch nicht vertraut sind, erstellen Sie ein Konto, um die Leistungsfähigkeit von Cloud SQL in der Praxis sehen und bewerten zu können. Neukunden erhalten außerdem ein Guthaben von 300 $, um Arbeitslasten auszuführen, zu testen und bereitzustellen.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-04 (UTC)."],[],[],null,["# Connect using a SQL Server client\n\n\u003cbr /\u003e\n\n[MySQL](/sql/docs/mysql/connect-admin-ip \"View this page for the MySQL database engine\") \\| [PostgreSQL](/sql/docs/postgres/connect-admin-ip \"View this page for the PostgreSQL database engine\") \\| SQL Server\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nYou can use the SQL Server command-line client to connect to Cloud SQL. This\npage describes how to connect a SQL Server client, whether running\nlocally on your client machine or on a Compute Engine VM, to your\nCloud SQL instance.\n| **Note:** For information about connecting a client to a Cloud SQL instance using the Cloud SQL Auth Proxy, see [Connect using the Cloud SQL Auth Proxy](/sql/docs/sqlserver/connect-auth-proxy). For information about connecting using private IP, see [Configure private IP](/sql/docs/sqlserver/configure-private-ip).\n\nBefore you begin\n----------------\n\nBefore you can use a `sqlcmd` client to connect to your Cloud SQL\ninstance, do the following:\n\n- Create a Cloud SQL instance, including configuring the default\n user.\n\n See [Create instances](/sql/docs/sqlserver/create-instance) and\n [Set the\n password for the default user account](/sql/docs/sqlserver/create-manage-users#user-root).\n- Optionally, create a Compute Engine VM instance and then\n connected to the instance using SSH.\n\n See [Create and\n start a VM instance](/compute/docs/instances/create-start-instance),\n [About SSH connections](/compute/docs/instances/ssh),\n or [Connect to\n Windows VMs using RDP](/compute/docs/instances/connecting-to-windows).\n- Determine how you'll connect to your instance.\n\n For the connection options and how to choose from among them, see\n [About connection options](/sql/docs/sqlserver/connect-overview).\n- Install the [SQL Server command-line tools](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools?view=sql-server-2017).\n\n\u003cbr /\u003e\n\nUse a SQL Server client on a local machine or a Compute Engine\nVM\n-----------------------------------------------------------------\n\nUsing a `sqlcmd` client to connect to your Cloud SQL\ninstance involves three high-level tasks:\n\n1. [Install the client](#install-mysql-client).\n2. [Configure access to your\n Cloud SQL instance](#configure-instance-mysql).\n3. [Connect to your Cloud SQL instance](#connect).\n\n### Install the client\n\nTo install the `sqlcmd` client, do the following: \n\n### Debian/Ubuntu\n\nFor Debian/Ubuntu, [install the applicable SQL Server command-line tools](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools?view=sql-server-2017#ubuntu).\n\n### CentOS/RHEL\n\nFor CentOS/RHEL, [install the applicable SQL Server command-line tools](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools?view=sql-server-2017#install-tools-on-rhel-7).\n\n### openSUSE\n\nFor openSUSE, [install the applicable SQL Server command-line tools](https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-suse?view=sql-server-2017#tools).\n\n### Other platforms\n\nSee the [landing page](https://docs.microsoft.com/en-us/sql/database-engine/install-windows/install-sql-server-database-engine?view=sql-server-2017) for installing SQL Server, as well as the\n[SQL Server downloads page](https://www.microsoft.com/en-us/sql-server/sql-server-downloads).\n\n### Configure access to your Cloud SQL\ninstance\n\nTo configure access to your instance, do the following:\n\n1. From the client machine or Compute Engine VM instance, use [What's my IP](http://ipv4.whatismyv6.com) to see the IP address of the client machine.\n2. Copy that IP address.\n3. In the Google Cloud console, go to the **Cloud SQL Instances** page.\n\n [Go to Cloud SQL Instances](https://console.cloud.google.com/sql)\n4. To open the **Overview** page of an instance, click the instance name.\n5. Select **Connections** from the SQL navigation menu.\n6. Select the **Networking** tab.\n7. In the **Authorized networks** section, click **Add network** and enter the IP address of the machine where the client is installed. **Note:** The IP addresses must be IPv4. That is, the IP addresses of the instance, and of the client machine that you authorize, both must be IPv4.\n8. Click **Done** . Then click **Save** at the bottom of the page to save your changes.\n9. [Connect](#connect) to your instance.\n\n### Connect to your Cloud SQL instance\n\nTo let you connect without encryption, the instance must have `requireSsl`\nset to **`false`** . In the Google Cloud console, the\n**Allow only SSL connections** checkbox must be cleared.\n\nFor more information about the SSL/TLS configuration of your instance, see\n[Configure SSL/TLS certificates](/sql/docs/sqlserver/configure-ssl-instance).\n\nTo connect to your instance, do the following:\n\n1. Confirm that you have [installed the client](#install-mysql-client) and [configured access to your instance](#configure-instance-mysql).\n2. Use the `sqlcmd` command to connect, by following steps similar to those in the examples on the [SQL Server quickstart](https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu?view=sql-server-2017#connect-locally) and [Use the utility](https://docs.microsoft.com/en-us/sql/ssms/scripting/sqlcmd-use-the-utility?view=sql-server-2017) pages.\n\n### Connect to your Cloud SQL instance using SSL/TLS\n\n\nUse the instructions in the\n[Client Initiated Encryption](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-encrypted-connections?view=sql-server-2017#client-initiated-encryption) section, and related sections, of the\n[Encrypting Connections to SQL Server on Linux](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-encrypted-connections?view=sql-server-2017) page.\n\n\u003cbr /\u003e\n\nWhat's next\n-----------\n\n\u003cbr /\u003e\n\n- Learn about [configuring an instance with a private IP address](/sql/docs/sqlserver/configure-private-ip).\n- Learn [more about SQL Server](https://docs.microsoft.com/sql/sql-server/sql-server-technical-documentation).\n\n\u003cbr /\u003e\n\nTry it for yourself\n-------------------\n\n\nIf you're new to Google Cloud, create an account to evaluate how\nCloud SQL performs in real-world\nscenarios. New customers also get $300 in free credits to run, test, and\ndeploy workloads.\n[Try Cloud SQL free](https://console.cloud.google.com/freetrial)"]]