Puedes usar el cliente de línea de comandos de SQL Server para conectarte a Cloud SQL. En esta página, se describe cómo conectar un cliente de SQL Server, ya sea de forma local en tu máquina cliente o en una VM de Compute Engine, a tu instancia de Cloud SQL.
Antes de comenzar
Antes de usar un cliente sqlcmd para conectarte a tu instancia de Cloud SQL, haz lo siguiente:
Crea una instancia de Cloud SQL y configura el usuario predeterminado.
Para que puedas conectarte sin encriptación, la instancia debe tener requireSsl configurado como false. En la consola de Google Cloud , la casilla de verificaciónSolo permitir conexiones SSL debe estar desmarcada.
Si es la primera vez que usas Google Cloud, crea una cuenta para evaluar el rendimiento de Cloud SQL en situaciones reales. Los clientes nuevos también obtienen $300 en créditos gratuitos para ejecutar, probar y, además, implementar cargas de trabajo.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 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)"]]