[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[],[],null,["# About linked servers\n\n\u003cbr /\u003e\n\nMySQL \\| PostgreSQL \\| SQL Server\n\n\u003cbr /\u003e\n\nLinked servers give SQL Server the ability to read data from remote data sources\nand execute commands on remote databases. This page provides information about\nCloud SQL instance permissions, things to consider when implementing linked\nservers, and the limitations of using linked servers.\n\nLinked server instance permissions\n----------------------------------\n\nTo set up linked servers, you need the following instance and user permissions:\n\n- `ALTER ANY LINKED SERVER`: Cloud SQL grants this permission when you add the `cloudsql enable linked servers` flag to your instance.\n- `ALTER ANY LOGIN`: Cloud SQL automatically grants this permission to the administrative user for the Cloud SQL instance. This permission allows you to create a mapping between a login on Cloud SQL and a security account on a linked server.\n\nFor a list of the default permissions available for Cloud SQL instances, see\n[Default SQL Server users](/sql/docs/sqlserver/users#default-users).\n\nFor information about how to grant the `ALTER ANY LINKED SERVER` or `ALTER ANY\nLOGIN` permission to additional accounts, see the example at [Granting server\npermissions](/sql/docs/sqlserver/users#grant-command).\n\nConsiderations when using linked servers\n----------------------------------------\n\nThis section has recommendations for handling security, performance, and\nreliability on linked servers.\n\n### Security\n\nTo mitigate potential\n[security vulnerabilities](https://www.netspi.com/blog/technical/network-penetration-testing/how-to-hack-database-links-in-sql-server/),\nyou need to ensure that linked servers have strong security protocols in place,\nsuch as the following:\n\n- Implement appropriate authentication and authorization mechanisms, such as [SSL encryption](/sql/docs/sqlserver/configure-ssl-instance).\n- Implement strict [password policies](https://learn.microsoft.com/en-us/sql/relational-databases/security/password-policy?view=sql-server-ver16).\n- Ensure that only authorized users have access to the linked server.\n- Ensure that sensitive data is properly encrypted and secured.\n- Ensure that logins only have access to the resources that you use during the configuration.\n\n### Performance\n\nThere are a few factors that might impact performance on linked servers:\n\n- Linked servers can introduce latency and degrade performance when queries are complex, depending on the volume of data each server transfers. This can cause problems for applications that require real-time data synchronization.\n- When you use linked servers to run a query, a database engine creates a new connection and fetches data for every query you run. Data isn't cached and the server might [copy the entire table across the network](https://www.brentozar.com/archive/2021/07/why-are-linked-server-queries-so-bad/) every time you use a linked server.\n- Cloud SQL can't [create an optimized execution plan](https://datasteve.com/2020/04/02/linked-server-in-sql-server-the-good-the-bad-and-the-way-to-make-it-perfect/) for the remote server because it doesn't know how the remote server handles indexes and statistics.\n\nTo optimize performance, do the following:\n\n- Carefully design your queries and ensure that only the necessary data is being transferred between servers.\n- Leverage the [SQL Server distributed queries\n feature](https://learn.microsoft.com/en-us/host-integration-server/core/query-processor2).\n- Distribute queries across multiple servers.\n- Regularly monitor and optimize your linked server configuration to help ensure that it's running smoothly.\n\n### Reliability\n\nAny interruptions or failures in the link between servers can lead to\nsignificant downtime and potentially cause data loss.\n\nTo ensure reliable operation, it's important to implement appropriate failover\nand redundancy mechanisms. This can include the following:\n\n- Implement a backup linked server for failover.\n- Monitor server availability and performance.\n- Regularly test and validate your linked server configurations.\n\nLimitations\n-----------\n\nLinked servers for Cloud SQL have the following limitations:\n\n- Linked servers can't use data sources other than SQL Server.\n- Active Directory Authentication isn't available for linked Servers.\n- If you're using Private Service Connect to connect to a Cloud SQL instance, then you need to [enable Private Service Connect outbound connectivity](/sql/docs/sqlserver/about-private-service-connect#psc-outbound) to use linked servers.\n\nFor a full list of limitations for linked servers, see [Unsupported features \\&\nservices](https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-editions-and-components-2019?view=sql-server-ver16#Unsupported).\n\nWhat's next\n-----------\n\n- Learn how to [enable, add, and configure linked\n servers](/sql/docs/sqlserver/manage-linked-servers)."]]