For the complete documentation index, see llms.txt. This page is also available as Markdown.

Connect to a database

Connecting to a database works the same for MySQL and PostgreSQL


All the details needed to connect to a database are shown on the specific database's overview page in the control panel.

The connection string shown in the overview can be used directly in most programs and programming languages. However, some tools instead require separate values for hostname, port, username, and password. These values can be extracted from the connection string.

For example, given the following connection string:

  • The database type is PostgreSQL.

  • The username is dbadmin.

  • The password is xxxyyy.

  • The hostname is db-4f959.database-v1.glesys.com (after the @ symbol).

  • The port is 5432 (the default port for PostgreSQL).

  • The database name is defaultdb.

  • The connection requires SSL encryption, as indicated by the ssl-mode=required parameter.

Custom users and databases

For databases and users you have created yourself, you can use the connection string builder on the overview page. This lets you create complete connection strings for your custom users and databases using the drop-down menus. If you click the eye icon, it even includes your password. Note that the drop-down menus only appear if you have created custom users and databases.

Example with DBeaver

After launching the DBeaver application, either click Database → New Database Connection from the menu or press Shift+Ctrl+N on the keyboard. This opens the dialog for creating a new database connection.

First, select the type of database—either MySQL or PostgreSQL. In this example, we want to connect to a PostgreSQL database. Click PostgreSQL, then click Next. (The procedure is pretty much the same for MySQL.)

In the next dialog box, enter all the necessary information for the database connection, such as hostname, port, database name, username, and password.

Once you’ve filled in all the required information on the Main tab, click the SSL tab. Here, check Use SSL. Under SSL mode, select require. Finally, click Finish.

Now, click the down-arrow icon in front of defaultdb under Connections. DBeaver should now connect to the database. You can then continue expanding the tree by clicking the down arrows until you see the defaultdb database and its contents.

From here, you can start working with your database—either by using the SQL console (SQL Editor → Open SQL Console) or by using the graphical interface to create and modify tables.

For example, if you expand Schemas, then public, and right-click on Tables, you can create new tables or view existing ones.

Retrieving connection details using the API

Use the database/connectiondetails endpoint to retrieve the connection string. To list available databases and users in an instance, use the database/details endpoint.

Last updated

Was this helpful?