Database Credentials

When you provision a Database on Aptible, you'll be provided with a set of Database Credentials.

Accessing Database Credentials

Database Credentials are available in the Dashboard. Click Reveal to show them.

Using Database Credentials

Database Credentials are presented as connection URLs. A large number of libraries can use those directly, but you can always break down the URL in components.

The structure is:

protocol://username:[email protected]:port/name
═══╦════   ═══╦════ ═══╦════ ═╦══ ═╦══ ═╦══
   ║          ║        ║      ║    ║    ╚╡► Database-dependent
   ║          ║        ║      ║    ╚═════╡► Port number
   ║          ║        ║      ╚══════════╡► Hostname
   ║          ║        ╚═════════════════╡► Password
   ║          ╚══════════════════════════╡► Username
   ╚═════════════════════════════════════╡► Database-dependent

❗️

Warning

The password in Database Credentials should be protected for security.

There are three ways to connect to a database using Database Credentials:

Direct Access

This set of credentials is usable with Network Integrations, and is also how Apps, other Databases, and Ephemeral SSH Sessions within the Stack can contact the Database. The credentials can be retrieved through aptible db:url and the Dashboard.

Database Endpoint

Database Endpoints allows users to expose Aptible Databases on the public internet. When a Database Endpoint is created, a separate set of Database Credentials is provided. Database Endpoints are useful if, for example, a third party needs to be granted access to the Aptible Database. This set of Database Credentials can be found in the Dashboard.

Database Tunnels

The aptible db:tunnel CLI command allows users to create a Database Tunnel which provides a convenient, ad-hoc method for users to connect to Aptible Databases from a local workstation. Database Credentials are exposed in the terminal when you successfully tunnel and are only valid while the db:tunnel is up. Database Tunnels persist until the connection is closed or for a maximum of 24 hours.

📘

Tip

The Database Credentials provides credentials for the aptible user, but you can also create your own users for database types that support multiple users such as PostgreSQL and MySQL. Refer to the database's own documentation for detailed instructions. If setting up a restricted user, refer to Aptible's community topic for extra considerations.

Note that certain Supported Databases provide multiple credentials. For more information about those, review our database-specific documentation.

Rotating Database Credentials

While using the built-in aptible user may be convenient, for Databases which support it (MySQL, PostgreSQL, Mongo, ES 7), Aptible recommends creating a separate user that is granted only the minimum permissions required by the application. The only way to rotate database credentials without any downtime is to create separate database users and update apps to use the newly created user's credentials. Additionally, these separate users limit the impact of security vulnerabilities because applications are not granted more permissions than they need.

The aptible user credentials can only be rotated by contacting Aptible Support. Please note that rotating the aptible user's credentials will involve an interruption to the app's availability.