Puoi utilizzare il client a riga di comando SQL Server per connetterti a Cloud SQL. Questa
pagina descrive come connettere un client SQL Server, in esecuzione
localmente sul tuo sistema client o su una VM Compute Engine, alla tua
istanza Cloud SQL.
Prima di iniziare
Prima di poter utilizzare un client sqlcmd per connetterti all'istanza Cloud SQL, esegui le seguenti operazioni:
Crea un'istanza Cloud SQL, inclusa la configurazione dell'utente
predefinito.
Per consentirti di connetterti senza crittografia, l'istanza deve avere requireSsl
impostato su false. Nella console Google Cloud , la casella di controllo
Consenti solo connessioni SSL deve essere deselezionata.
Se non conosci Google Cloud, crea un account per valutare le prestazioni di Cloud SQL in scenari reali. I nuovi clienti ricevono anche 300 $ di crediti per l'esecuzione, il test e
il deployment di workload senza costi aggiuntivi.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 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)"]]