Skip to main content

Connecting to the Server

In this tutorial, we'll walk through the steps to establish a direct connection to the PostgreSQL database used by Nakama.

Prerequisites

  • Access: Ensure you have access to your Nakama server.
  • Credentials: Have your PostgreSQL connection details (host, port, database, username, and password).
  • Client: Install a PostgreSQL client such as psql or use a GUI tool like pgAdmin.

Connection Details

Typical connection details for the Nakama PostgreSQL server are:

  • Host: your-nakama-server-host
  • Port: 5432 (default PostgreSQL port)
  • Database: nakama
  • User: your-database-username
  • Password: your-database-password

Connecting Using psql

Open your terminal and run the following command:

psql -h your-nakama-server-host -p 5432 -U your-database-username -d nakama

You will be prompted to enter your database password.

Using a .pgpass File

To avoid entering your password every time:

  1. Create or edit the ~/.pgpass file with the following entry:
    your-nakama-server-host:5432:nakama:your-database-username:your-database-password
  2. Secure the file permissions:
    chmod 600 ~/.pgpass

Connecting Using pgAdmin

If you prefer a graphical interface:

  1. Open pgAdmin and create a new server connection.
  2. In the server settings, enter the connection details provided above.
  3. Save your configuration and connect.

Additional Resources