La conectividad de IP pública es la opción más adecuada cuando la base de datos de origen es externa a Google Cloud
y tiene una dirección IPv4 y un puerto TCP a los que se puede acceder externamente. Si la base de datos de origen está alojada en otra VPC de Google Cloud, la forma más sencilla de conectar la base de datos de origen con la instancia de Cloud SQL es usar el emparejamiento de VPCs.
Si tu base de datos de origen es externa a Google Cloud, añade la dirección IP de salida (y el puerto 3306) de la base de datos de destino como regla de firewall de entrada en la red de origen. En términos generales (la configuración de tu red puede ser diferente), haz lo siguiente:
Abre las reglas de cortafuegos de red de la máquina de la base de datos de origen.
Crea una regla de entrada.
Selecciona MySQL en Tipo de regla.
Define el protocolo como TCP.
Define el intervalo de puertos en 3306.
Define la dirección IP de origen como la dirección IP de salida de la base de datos de destino. Por ejemplo:
12.20.36.126/32. La designación /32 en la notación CIDR limita el intervalo de direcciones a una sola dirección, la proporcionada. Se define la máscara de subred en 255.255.255.255. Si la instancia de Cloud SQL que has creado es una instancia de alta disponibilidad, incluye las direcciones IP de salida de la instancia principal y de la secundaria.
[[["Es fácil de entender","easyToUnderstand","thumb-up"],["Me ofreció una solución al problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Es difícil de entender","hardToUnderstand","thumb-down"],["La información o el código de muestra no son correctos","incorrectInformationOrSampleCode","thumb-down"],["Me faltan las muestras o la información que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-08-21 (UTC)."],[[["\u003cp\u003ePublic IP connectivity is suitable when the source database is outside Google Cloud and has an externally accessible IPv4 address and TCP port.\u003c/p\u003e\n"],["\u003cp\u003eFor source databases external to Google Cloud, add the destination database's outgoing IP address and port 3306 as an inbound firewall rule on the source network.\u003c/p\u003e\n"],["\u003cp\u003eThe source IP address in the inbound rule should be set to the destination database's outgoing IP address, using CIDR notation such as \u003ccode\u003e12.20.36.126/32\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIf the Cloud SQL instance is high availability, include the outgoing IP addresses for both the primary and secondary instances in the firewall rule.\u003c/p\u003e\n"],["\u003cp\u003eUsing SSL/TLS during source connection profile definition is highly recommended to secure data transmission.\u003c/p\u003e\n"]]],[],null,["# Configure connectivity using IP allowlists\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nMySQL \\| [PostgreSQL](/database-migration/docs/postgres/configure-connectivity-ip-allowlists \"View this page for the PostgreSQL version of Database Migration Service.\") \\| [PostgreSQL to AlloyDB](/database-migration/docs/postgresql-to-alloydb/configure-connectivity-ip-allowlists \"View this page for the PostgreSQL to AlloyDB version of Database Migration Service.\")\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nOverview\n--------\n\nPublic IP connectivity is most appropriate when the source database is external to Google Cloud\nand has an externally accessible IPv4 address and TCP port. If the source\ndatabase is hosted in another VPC in Google Cloud, then the easiest way to\nconnect the source database with the Cloud SQL instance is by using VPC Peering.\n\nIf your source database is external to Google Cloud, then add the destination database's **outgoing\nIP address** (and port 3306) as an inbound firewall rule on the source network. In\ngeneric terms (your specific network settings may differ), do the following:\n\n1. Open the source database machine's network firewall rules.\n\n2. Create an inbound rule.\n\n3. Set the Rule type to `MySQL`.\n\n4. Set the Protocol to `TCP`.\n\n5. Set the Port range to 3306.\n\n6. Set the Source IP address to the destination database's **outgoing IP address** . For example:\n `12.20.36.126/32`. (The /32 designation in CIDR notation limits the\n address range to one address only, the one provided. It's setting the subnet\n mask to `255.255.255.255`). If the Cloud SQL instance you created\n is a high availability instance, include the outgoing IP addresses for both\n the primary and the secondary instance.\n\n\n You can use the **SQL Instances** page in the Google Cloud Console to [locate the outgoing IP addresses](/database-migration/docs/mysql/debugging-connectivity#locateoutgoingIPaddress).\n\n \u003cbr /\u003e\n\n7. Save the firewall rule and exit.\n\n| You can test connectivity by adding another, temporary inbound firewall rule using the IP address of your local machine (or `0.0.0.0/0` to allow access from anywhere), and then running the following telnet command: `telnet [SOURCE_DB_IP_ADDRESS] 3306`. The connection should succeed. Delete the temporary firewall rule.\n\nIt's also highly recommended to use SSL/TLS during the definition of the source\nconnection profile so that the data sent to and received by the source is\nsecure.\n[Learn more](/sql/docs/mysql/authorize-ssl) about SSL/TLS certificates for MySQL."]]