> For the complete documentation index, see [llms.txt](https://docs.glesys.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.glesys.com/products/database/how-tos/connect-to-a-database.md).

# Connect to a database

***

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

<figure><img src="/files/CPeQBHZnC0r63wIDOtid" alt=""><figcaption></figcaption></figure>

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:

```
postgresql://dbadmin:xxxyyy@db-4f959.database-v1.glesys.com:5432/defaultdb?ssl-mode=required
```

* The database type is *PostgreSQL*.
* The username is *dbadmin*.
* The password is *xxxyyy*.
* The hostname is [*db-4f959.database-v1.glesys.com*](http://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, replace *dbadmin* with the user, and *defaultdb* with the database in the connection string. For example, to connect with the user *my\_user* to the database *my\_own\_db*, the connection string will be:

```
postgresql://my_user:zzzxxx@db-4f959.database-v1.glesys.com:5432/my_own_db?ssl-mode=required
```

## Example with DBeaver

After launching the DBeaver application, either click **Database → New Database Connection** from the menu or press <kbd>Shift+Ctrl+N</kbd> 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.)

<div align="left"><figure><img src="/files/rCN9paO3RLCTD8AGukgY" alt=""><figcaption></figcaption></figure></div>

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

<div align="left"><figure><img src="/files/1dS8TIkTe4VA2rG28AJY" alt=""><figcaption></figcaption></figure></div>

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**.

<div align="left"><figure><img src="/files/x0qzdlRIRQjFrBOGf80F" alt=""><figcaption></figcaption></figure></div>

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.

<div align="left"><figure><img src="/files/qdHTVd2eCM8Y0fQGnAIx" alt=""><figcaption></figcaption></figure></div>

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](https://github.com/GleSYS/API-docs/wiki/API-Documentation#databaseconnectiondetails) endpoint to retrieve the connection string. To list available databases and users in an instance, use the [database/details](https://github.com/GleSYS/API-docs/wiki/API-Documentation#databasedetails) endpoint.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.glesys.com/products/database/how-tos/connect-to-a-database.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
