[[["易于理解","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-08-07。"],[],[],null,["# Cloud SQL built-in database authentication\n\n\u003cbr /\u003e\n\n[MySQL](/sql/docs/mysql/built-in-authentication \"View this page for the MySQL database engine\") \\| PostgreSQL \\| SQL Server\n\n\u003cbr /\u003e\n\nThis page describes how built-in authentication works on Cloud SQL instances\nand how database administrators can set password policies for local database users.\n\nIntroduction\n------------\n\nAuthentication is the process of verifying the identity of a user who is\nattempting to access an instance. Cloud SQL uses the following types of\nauthentication for database users:\n\n- The database's built-in authentication uses a username and a password to authenticate local database users. The current page describes this type of authentication.\n- IAM database authentication uses IAM to authenticate a user. For more information, see [Overview of Cloud SQL IAM database authentication](/sql/docs/postgres/authentication).\n\nAlthough IAM database authentication is more secure and reliable, you might prefer to use\nbuilt-in authentication or a hybrid authentication model that includes\nboth authentication types.\n\nYou might create and manage local database users locally within a database to\nallow specific persons or applications to access a database. Such database users\nown the objects they create in the database. Cloud SQL offers strong\nbuilt-in password enforcement. You can define and enable such enforcement\nthrough password policies.\n| **Note:** Password policies don't apply to hashed passwords.\n\nInstance password policies\n--------------------------\n\nYou can set a password policy at the instance level when\nyou [create an instance](/sql/docs/postgres/create-instance).\n\nA password policy for an instance can include the following options:\n\n- **Minimum length**: specify the minimum number of characters that the password must have.\n- **Password complexity**: check if the password is a combination of lowercase, uppercase, numeric, and non-alphanumeric characters.\n- **Restrict password reuse**: specify the number of previous passwords that you can't reuse.\n- **Disallow username**: prevent the use of the username in the password.\n- **Set password change interval**: specify the minimum duration after which you can change the password.\n\n\u003cbr /\u003e\n\nYou need to explicitly enable a password policy at the instance level. You can\nmodify it later by [editing the instance](/sql/docs/postgres/edit-instance).\n| **Note:** When you enable a password policy, due to password policy verification, statements that create users or change user passwords cause additional latency usually spanning less than 200ms.\n\nUser password policies\n----------------------\n\nWhile [creating a user](/sql/docs/postgres/create-manage-users#creating),\nyou can set the following password usage restrictions:\n\n- **Set password to expire**: specify the number of days after which the password expires and you need to create a new one.\n- **Lock after failed attempts**: specify the number of times that you can try the password incorrectly before the account is locked.\n\nYou can also modify user password policies.\n\nThe status of a user, indicating whether their password has expired or they're\nlocked out, is visible when you [list the users](/sql/docs/postgres/create-manage-users#list_users)\nof the instance. You can unlock users and change the password from the Users page.\n\nCloud SQL built-in authentication for read replicas\n---------------------------------------------------\n\nYou manage password policies for replicas on the primary instance.\nYou can't separately modify password policies for read replicas.\n\nWhen you promote an instance, you need to re-enable the instance password policy,\nalong with the policy options.\n\nWhat's next\n-----------\n\n- [Create an instance and set the password policy](/sql/docs/postgres/create-instance).\n- [Create users with built-in authentication](/sql/docs/postgres/create-manage-users)."]]