When you create an ApsaraDB RDS for PostgreSQL instance and enable Babelfish for the RDS instance, the management account is initialized and can be used to manage Babelfish or PostgreSQL. After the RDS instance is created, you can manually create a Babelfish management account. You can also create standard accounts after you connect your application to the RDS instance over the Tabular Data Stream (TDS) port.

Create a Babelfish management account

  1. Access RDS Instances, select a region at the top, and then click the ID of the target RDS instance.
  2. In the left-side navigation pane, click Accounts.
  3. Click Create Account. In the panel that appears, set the Account Type parameter to Privileged Account. Babelfish management account
    Note
    • This topic describes how to create a Babelfish management account and how to grant logon permissions to the account. The parameters that are used to create a Babelfish management account are the same as the parameters that are used to create an account for the RDS instance. For more information, see Create an account on an ApsaraDB RDS for PostgreSQL instance.
    • In this example, a Babelfish management account named babelfish_user is created.
  4. Run the following command to log on to the RDS instance by using the babelfish_user account:
    psql -h <Endpoint of the RDS instance> -p 5432 -U babelfish_user -d babelfish_db
    Note For more information about how to obtain the endpoint of the RDS instance, see View and change the internal and public endpoints and port numbers of an ApsaraDB RDS for PostgreSQL instance.
  5. Run the following command to grant permissions to the babelfish_user account to connect to the RDS instance over the TDS port:
    call sys.babel_initialize_logins('babelfish_user');
    
    GRANT sysadmin to babelfish_user;
    Note The sysadmin account in PostgreSQL is used in a similar manner to the SA account in SQL Server.

Create a Babelfish standard account

After you connect your application to the RDS instance over the TDS port, you can create a standard account.

  1. Connect your application to the RDS instance over the TDS port.
    Note If you want to connect your application to the RDS instance over the TDS port, an SQL Server client is required. For more information about how to download an SQL Server client and how to configure connection parameters, see Use clients to connect to an ApsaraDB RDS for PostgreSQL instance with Babelfish enabled. In this example, sqlcmd is used.
    sqlcmd -S pgm-****.pg.rds.aliyuncs.com,1433 -U babelfish_user
  2. Execute the following statements to create a standard account:
    -- Creates the login test_babelfish with password 'Test123456!'.  
    CREATE LOGIN test_babelfish   
        WITH PASSWORD = 'Test123456!';  
    GO  
    
    -- Creates a database user for the login created above.  
    CREATE USER test_babelfish FOR LOGIN test_babelfish;  
    GO 
    Note The method that is used to create standard accounts in this step is an example. For information about more methods, see CREATE USER (Transact-SQL).
  3. View the information about the account that you want to use to connect to the RDS instance over the TDS port.
    Note You cannot create, view, modify, or delete the accounts that are connected over the TDS port in the ApsaraDB RDS console.
    SELECT name 
    FROM sys.server_principals;
    GO
    The following result is returned:Results

Related operations

Operation Description
CreateAccount Creates a database account.